Program must be written in C#. Any steps or directions would be very helpful. No
ID: 3587683 • Letter: P
Question
Program must be written in C#. Any steps or directions would be very helpful. Not sure where to start.
You Do It Using if-else Statements In the next steps, you write a program that requires using multiple, nested if-else statements to accomplish its goal-determining whether any of the three integers entered by a user are equal 1. Open a new file or project named CompareThreeNumbers, and write the first lines necessary for the class using System; using static System.Console class CompareThreeNumbers 2. Begin a Main) method by declaring a string for input and three integers that will hold the input values static void MainO string numberString; int numl, num2, num3; 3. Add the statements that retrieve the three integers from the user and assign them to the appropriate variables Write("Enter an integer"; numberString ReadLine O nun1 Convert. ToInt32(numberSt ring); Write("Enter an integer"; numberSt ring = ReadLine(); num2 Convert.ToInt32(numberString); Write("Enter an integer" numberString = ReadLine(); num3 Convert.ToInt32 (numberString); In the chapter "Introduction to Methods," you will learn to write methods, which will allow you to avoid repetitive code like that shown here. (continues)Explanation / Answer
using System.IO;
using System;
class Program
{
static void Main()
{
int int1,int2,int3;
string input;
Console.Write("Input 1st number: ");
input = Console.ReadLine();
int1= Convert.ToInt32(input);
Console.Write("Input 2nd number: ");
input = Console.ReadLine();
int2= Convert.ToInt32(input);
Console.Write("Input 3nd number: ");
input = Console.ReadLine();
int3= Convert.ToInt32(input);
if (int1 == int2)
{
if(int1 == int3)
{
Console.WriteLine("Three are equal");
}
else
{
Console.WriteLine("First two are are equal");
}
}
else{
if((int1 == int3)){
Console.WriteLine("First and Last are equal");
}else{
if((int2 == int3)){
Console.WriteLine("Last two are equal");
}else{
Console.WriteLine("no two numbers are equal");
}
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.