C
C#ā€¢14mo 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ā€¢14mo ago
Did you flunk basic math?
geno
genoOPā€¢14mo ago
quite possibly
Pobiega
Pobiegaā€¢14mo ago
What's the order of mathematical operations?
geno
genoOPā€¢14mo ago
pemdas
Pobiega
Pobiegaā€¢14mo ago
Yup!
Angius
Angiusā€¢14mo ago
So what's 100 + 100 + 100 / 3 gonna be, if you keep the PEMDAS rule?
geno
genoOPā€¢14mo ago
wat nvm i just realised it
Pobiega
Pobiegaā€¢14mo ago
Good job!
geno
genoOPā€¢14mo ago
thanks for the constructive criticism ig
Pobiega
Pobiegaā€¢14mo ago
We solved it thou, don't see why you'd have to guess.
geno
genoOPā€¢14mo 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ā€¢14mo ago
Bedmas šŸ‡¬šŸ‡§
arion
arionā€¢14mo ago
Brackets vs Parenthesis when the funny flip
Accord
Accordā€¢14mo 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.
Want results from more Discord servers?
Add your server