✅ my code to calculate an average seems to be wrong

using System;
using System.Reflection.Metadata;

namespace startover
{
internal class Program
{
static void Main(string[] args)
{
//window setting
Console.Title = "window name";
Console.ForegroundColor = ConsoleColor.Green;
Console.WindowHeight = 40;
//main part of program
int x;
int y;
int z;


Console.Write("whats x? ");
x = Convert.ToInt32( Console.ReadLine());

Console.Write("whats y? ");
y = Convert.ToInt32( Console.ReadLine());

Console.Write("whats z? ");
z = Convert.ToInt32( Console.ReadLine());

int result = z+y+x/3;
Console.WriteLine(result);



Console.ReadKey();
}
}
}
using System;
using System.Reflection.Metadata;

namespace startover
{
internal class Program
{
static void Main(string[] args)
{
//window setting
Console.Title = "window name";
Console.ForegroundColor = ConsoleColor.Green;
Console.WindowHeight = 40;
//main part of program
int x;
int y;
int z;


Console.Write("whats x? ");
x = Convert.ToInt32( Console.ReadLine());

Console.Write("whats y? ");
y = Convert.ToInt32( Console.ReadLine());

Console.Write("whats z? ");
z = Convert.ToInt32( Console.ReadLine());

int result = z+y+x/3;
Console.WriteLine(result);



Console.ReadKey();
}
}
}
when i plug in 100 for the three values i get 233
14 Replies
Pobiega
Pobiega3y ago
Did you flunk basic math?
⃟⃟⃟⃟⃟⃟⃟⃟⃟geno
quite possibly
Pobiega
Pobiega3y ago
What's the order of mathematical operations?
Pobiega
Pobiega3y ago
Yup!
Angius
Angius3y ago
So what's 100 + 100 + 100 / 3 gonna be, if you keep the PEMDAS rule?
⃟⃟⃟⃟⃟⃟⃟⃟⃟geno
wat nvm i just realised it
Pobiega
Pobiega3y ago
Good job!
⃟⃟⃟⃟⃟⃟⃟⃟⃟geno
thanks for the constructive criticism ig
Pobiega
Pobiega3y ago
We solved it thou, don't see why you'd have to guess.
⃟⃟⃟⃟⃟⃟⃟⃟⃟geno
ima be honest i take fault in my stupidity but you should have set your expectations low when you saw that beginner tag
Mayor McCheese
Bedmas 🇬🇧
arion
arion3y ago
Brackets vs Parenthesis when the funny flip
Accord
Accord3y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?