C
C#•2y ago
geno

āœ… 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
Pobiega•2y ago
Did you flunk basic math?
geno
genoOP•2y ago
quite possibly
Pobiega
Pobiega•2y ago
What's the order of mathematical operations?
geno
genoOP•2y ago
pemdas
Pobiega
Pobiega•2y ago
Yup!
Angius
Angius•2y ago
So what's 100 + 100 + 100 / 3 gonna be, if you keep the PEMDAS rule?
geno
genoOP•2y ago
wat nvm i just realised it
Pobiega
Pobiega•2y ago
Good job!
geno
genoOP•2y ago
thanks for the constructive criticism ig
Pobiega
Pobiega•2y ago
We solved it thou, don't see why you'd have to guess.
geno
genoOP•2y ago
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
Mayor McCheese•2y ago
Bedmas šŸ‡¬šŸ‡§
arion
arion•2y ago
Brackets vs Parenthesis when the funny flip
Accord
Accord•2y 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?