C
C#ā€¢8mo 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ā€¢8mo ago
Did you flunk basic math?
geno
genoā€¢8mo ago
quite possibly
Pobiega
Pobiegaā€¢8mo ago
What's the order of mathematical operations?
geno
genoā€¢8mo ago
pemdas
Pobiega
Pobiegaā€¢8mo ago
Yup!
Angius
Angiusā€¢8mo ago
So what's 100 + 100 + 100 / 3 gonna be, if you keep the PEMDAS rule?
geno
genoā€¢8mo ago
wat nvm i just realised it
Pobiega
Pobiegaā€¢8mo ago
Good job!
geno
genoā€¢8mo ago
thanks for the constructive criticism ig
Pobiega
Pobiegaā€¢8mo ago
We solved it thou, don't see why you'd have to guess.
geno
genoā€¢8mo 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ā€¢8mo ago
Bedmas šŸ‡¬šŸ‡§
arion
arionā€¢8mo ago
Brackets vs Parenthesis when the funny flip
Accord
Accordā€¢8mo 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
More Posts
āœ… Message me if you are good at C# I need some help I am beginner I know bit Javascript and a Bit C#Message me if you are good at C# I need some help I am beginner I know bit Javascript and a Bit C#ā” Show error text message under update text box through server validation without refreshingSo basically I want to show an error text message if the user updates and submits an invalid value, ā” Roslyn analyzer rules extractionPls guide me with a solution for extracting a set of rules from any RoslynAnalyzer.dll that it contaāœ… filling byte array with a random intbest approach? ```cs BinaryPrimitives.WriteInt32BigEndian(bytes, Random.Shared.Next(5000000)); //vs āœ… How to pattern-match a `Rune`?is this the best I can do? ```cs myRune switch { _ when myRune == (Rune)'A' => 3, _ when myRā” EF Core LINQ - Many to Many Search with && and ||Hi there, I have a 3 table structure for file storage that I would like to search, consisting of thā” Where to startHello all! I've pinged this question in the chat quite a few times and have gotten many useful respoā” NavigationManager: TaskCancelledExceptionI've got an OAuth login button: ```csharp @inject IOptionsMonitor<BaasOptions> Options; @inject Navā” EFCore: Unique Category NameI have an issue with the entity "Category" that I have. Each "Target" Entity can have several categā” Flip GameObject with ParentYo im using an GameObject for my Mele range, and i wanted to do it flip with my parent but my code i