Question: Help with this question. Modify the program to print 1st, 2nd, 3rd, 4th and 5th rather than 1th, 2th, etc., without introducing redundant statements (Hint:

Help with this question.

Modify the program to print "1st", "2nd", "3rd", "4th" and "5th" rather than "1th", "2th", etc., without introducing redundant statements (Hint: Precede the "if-else" statement with[i] a separate if-else statement that determines the appropriate ending based on the number).

Help with this question. Modify the program to print "1st", "2nd", "3rd",

2 import java.util.ArrayList; 3 import java.util.Scanner; 4 5 public class MostPopularOS public static void main (String [] args) Scanner scnr new Scanner (System.in) ArrayList(); int nthOS; /User input, Nth most popular OS 10 operatingSystems.add (new String("Windows 7")); operatingSystems.add (new String("Windows XP")); operatingSystems.add (new String("OS X")); operatingSystems.add (new String("Windows Vista")); operatingSystems.add (new String("Windows 8")); operatingSystems.add (new String("Linux")); operatingSystems.add (new String("Other")); 12 14 15 16 17 System.out.print("Enter N (1-7): "); nthoS scnr.nextInt); 20 21 if ((nthoS1) && (nthOS7)) 23 24 25 26 27 System.out.print("The " nthOs + "th most popular OS is "); System.out.println (operatingSystems.get (nthOS- 1))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!