Program: In this program, we run a do-while loop and display a menu for the user, take input from the user and display the output using switch case statements. The do-while loop ends when the user enters 0.
Code:
import java.util.Scanner;
public class Loop {
public static void main(String[] args) {
//Create Scanner class instance
Scanner scan = new Scanner(System.in);
//Define variable for userinput
int userInput;
//Start the do-while loop
do {
//Display message
System.out.println("Please select one of the following tasks to continue: ");
System.out.println("1. Option 1 \n2. Option 2 \n3. Option 3 \n4. Option 4 \n5. Exit");
//Take user input from keyboard
userInput = scan.nextInt();
//Switch case statement
switch (userInput){
case 1:
System.out.println("Do the option 1");
break;
case 2:
System.out.println("Do the option 2");
break;
case 3:
System.out.println("Do the option 3");
break;
case 4:
System.out.println("Do the option 4");
break;
case 0:
System.out.println("Terminate the program");
break;
default:
System.out.println("Invalid task");
break;
}
}
//While loop condition
while(userInput!=0);
}
}
![import java.util.Scanner; public class Loop { public static void main(String[] args) { 3 //Create Scanner class instance Scan](http://img.homeworklib.com/questions/2c87cdc0-5917-11eb-be99-5fa74dabd198.png?x-oss-process=image/resize,w_560)
Output:

java program QUESTION 2: 1. Write a do-while loop that asks the user to select a...
Write a java program that makes use of the ‘DO WHILE ’ loop. The program asks a user to enter information about several of their friends. The information is their last name, the state they live in, their age, and their expected graduation year. After you enter one friend, write out each individually. You must use JOptionPane to input the 4 fields, and to output the 4 fields. Refer to the textbook Code Listing 4-6 to see how to use...
Write a Program that has a menu with a layout below, that asks the user if they want to: 1. Converts from feet and inches to meter and centimeters 2. Converts from meter and centimeters to feet and inches 3. Quit the program The program should continue as long as the user asks it to. The program will use a switch statement for the menu option selection. Either a do loo or a do-while loop can be used for the overall...
The purpose of this assignment is to get experience with an
array, do while loop and read and write file operations.
Your goal is to create a program that reads the exam.txt file
with 10 scores. After that, the user can select from a 4 choice
menu that handles the user’s choices as described in the details
below. The program should display the menu until the user selects
the menu option quit.
The project requirements:
It is an important part...
1. Create a String variable named menuChoice. 2. Display 3 options for your program. I recommend using 3 System.out.println statements and a 4th System.out.print to show "Enter your Selection:". This needs to be inside the do -- while loop. A. Deposit Cash. B. Withdraw Cash X. Exit Enter your Selection: 3. Prompt for the value menuChoice. 4. If menuChoice is "A", display "Do Deposit" and redisplay the menu. If menuChoice is "B", display "Do withdrawal" and redisplay the menu. If...
Java Letter Counter: Write a program that asks the user to enter a string, 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 string. Must use a do while loop and a counter!!!!
Write codes that will produce the screen as shown Firstly, the program prompts user to enter his name. Then it will display Hello <user name>. Next it prints out a menu which contains 5 options (1- add two integers, 2- add two strings, 3- compute factorial, 4- reverse a string, 5- quit program). Code all 5 tasks appropriately. When the task is completed (not including quitting program of course), the menu pops up again and asks user to try...
HELP IN JAVA: WHILE LOOP: Write a program that asks the user to enter a number of seconds. This number should be less than or equal to 32767 because that is the largest number pep8 can handle. Your program should then output the number of hours, minutes, and seconds on the planet of Crypton, where there are 64 seconds in a minute and 32 minutes in an hour.
In Java, write a program using a loop that asks the user to enter a series of decimal numbers. The user must enter -88 to end the input of the decimal numbers. After the user enters all numbers, the program should display the sum of all numbers entered.
Project 1, Program Design 1. Write a C program replace.c that asks the user to enter a three-digit integer and then replace each digit by the sum of that digit plus 6 modulus 10. If the integer entered is less than 100 or greater than 999, output an error message and abort the program. A sample input/output: Enter a three-digit number: 928 Output: 584 2. Write a C program convert.c that displays menus for converting length and calculates the result....
Write a Java application program to generate a calendar for the year 2019 from January to December. Give users the option to display 1 month, 3 months, or 12 months at a time. For 1 month - The user will need to be able to type what month they want to display For 3 months - The user will need to be able to type in the starting month For 12 months - All months will need to be visible...