Question

In: Computer Science

The program asks user to enter three integers, and the displays a message indicating whether the...

The program asks user to enter three integers, and the displays a message indicating whether the numbers are in sequential order, in reverse order or in neither order. Find the errors and correct the program codes in the if comparison expressions. (10 points)

1.     using System;

2.     using static System.Console;

3.

4.     class Sorting

5.     {

6.              static void Main()

7.              {

8.                       int num1, num2, num3;

9.                       string snum1, snum2, snum3;

10.                    Write ("Enter first number ");

11.                    snum1 = ReadLine();

12.                    num1 = Convert.ToInt32(snum1);

13.                    Write ("Enter second number ");

14.                    snum2 = ReadLine();

15.                    num2 = Convert.ToInt32(snum2);

16.                    Write ("Enter third number ");

17.                    snum3 = ReadLine();

18.                    num3 = Convert.ToInt32(snum3);

19.                    if (num1 > num2 && num2 <= num3)

20.                             WriteLine ("Numbers are in sequential order");

21.                    else

22.                             if (num1 < num2 && num2 == num3)

23.                                      WriteLine ("Numbers are in reverse order");

24.                    else

25.                             WriteLine ("Numbers are in neither sequential nor reverse order");

26.           }

27. }

Solutions

Expert Solution

using System;
     using static System.Console;
     class Sorting{
              static void Main()
              {

                       int num1, num2, num3;

                       string snum1, snum2, snum3;
                    Write ("Enter first number ");

                    snum1 = ReadLine();

                    num1 = Convert.ToInt32(snum1);

                    Write ("Enter second number ");

                    snum2 = ReadLine();

                    num2 = Convert.ToInt32(snum2);
                    Write ("Enter third number ");
                    snum3 = ReadLine();

                    num3 = Convert.ToInt32(snum3);
                    // here we have to check the sequence
                    // like num1 should be less than num2 and num2 should be less than num3
                    if (num1 < num2 && num2 < num3)
                             WriteLine ("Numbers are in sequential order");
                    else
                    // here we should check of descending order
                    // num1 should be greater than num2 and num3
                    if (num1 > num2 && num2>num3)
                        WriteLine ("Numbers are in reverse order");
                    else
                        WriteLine ("Numbers are in neither sequential nor reverse order");

           }

}

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME


Related Solutions

Write a C++ program that asks the user to enter in three numbers and displays the...
Write a C++ program that asks the user to enter in three numbers and displays the numbers in ascending order. If the three numbers are all the same the program should tell the user that all the numbers are equal and exits the program. Be sure to think about all the possible cases of three numbers. Be sure to test all possible paths. Sample Runs: NOTE: not all possible runs are shown below. Sample Run 1 Welcome to the order...
Write a program, ArrayRange, that asks the user to input integers and that displays the difference...
Write a program, ArrayRange, that asks the user to input integers and that displays the difference between the largest and the smallest. You should ask the user the number of integers s/he would like to enter (this will allow you to set the length of the array). Allow the user to input all the numbers and then store them in the array. Search the array for the largest number, then search for the smallest, and finally compute the calculation. Display...
Write a class that asks a user to enter three integers. Display them in ascending and...
Write a class that asks a user to enter three integers. Display them in ascending and descending order. Save the file as Sorting.java Again, Don’t forget to create the application/project  SortingTest.java Class that has the main method and an object to use the Sorting class.
Question Write a C program that asks the user to enter two integers x and n....
Question Write a C program that asks the user to enter two integers x and n. Then the program computes xn (=x * x * x …… (n times)) using for loop. and give me an output please use printf and scanf #include int main(void) {     //Declare required variables             //read two integers x , n from the keyboard                 //compute xn using for loop                     printf("< Your name >\n");...
Write a program that asks the user to enter the name of a file, and then...
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad or another text editor to create a sample file that can be used to test the program. Sample Run java FileLetterCounter Enter file name: wc4↵ Enter character to count: 0↵ The character '0' appears in the file...
Program should be written in Java a) Write a program that asks the user to enter...
Program should be written in Java a) Write a program that asks the user to enter the approximate current population of India. You should have the computer output a prompt and then YOU (as the user should enter the population.)  For testing purposes you may use the value of 1,382,000,000 from August 2020. Assume that the growth rate is 1.1% per year. Predict and print the predicted population for 2021 and 2022. The printout should include the year and the estimated...
Design the logic for a program that allows a user to enter 20 numbers, then displays...
Design the logic for a program that allows a user to enter 20 numbers, then displays them in the reverse order of entry. Design the logic for a program that allows a user to enter 20 numbers, then displays each number and its difference from the numeric average of the numbers entered. The program is C++. I need a Pseudocode
Write a Java program that asks the user to enter an integer that is used to...
Write a Java program that asks the user to enter an integer that is used to set a limit that will generate the following four patterns of multiples of five using nested loops •Ascending multiples of five with ascending length triangle •Ascending multiples of five with descending length (inverted) triangle •Descending multiples of five with ascending length triangle •Descending multiples of five with descending length (inverted) triangle Use error checking to keep asking the user for a positive number until...
In Python write a program that asks the user to enter the monthly costs for the...
In Python write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance the program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. your program MUST have BOTH a main function AND a function named calcExpenses to calculate the expenses. DO NOT display the expenses inside of the calcExpenses function!!...
Write a program that asks the user to enter an unsigned number and read it. Then...
Write a program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6. COMMENT COMPLETE CODE PLEASE
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT