Please solve this by creating well-formed pseudocode: University meal Plan Selec
ID: 3676713 • Letter: P
Question
Please solve this by creating well-formed pseudocode:
University meal Plan Selector The university offers the following meal plans:
Plan 1: 7 meals per week for $560 per semester
Plan 2: 14 meals per week for $1,095 per semester
Plan 3: Unlimited meals for $1,500 per semester
Design a menu-driven program that allows a user to select a meal plan. The program should ask the user for the number of semesters and then display the price for the plan. The following flowchart depicts the desired logic flow for a solution.
Explanation / Answer
SolutionDemo.java
import java.util.Scanner;//keybard inputting class
public class SolutionDemo {
public static void main(String[] args) {
int noofsemisters,Totalprice ;//noofsemisters,totalprice are variables
System.out.println("1. 7 meals per week for $560 per semester");
System.out.println("2. 14 meals per week for $1,095 per semester");
System.out.println("3. Unlimited meals for $1,500 per semester");
System.out.println("4.end the program");
Scanner sc = new Scanner(System.in);
System.out.println("enter your selection");
int choice = sc.nextInt();//command line iputting
String monthString;
switch (choice) {//switch case for selecting user chioce
case 1:
System.out.println("Enter the no of semisters :");
noofsemisters = sc.nextInt();
Totalprice=560*noofsemisters;
System.out.println("Total price for the plan :"+Totalprice+"$");
break;
case 2:
System.out.println("Enter the no of semisters :");
noofsemisters = sc.nextInt();
Totalprice=1095*noofsemisters;
System.out.println("Total price for the plan :"+Totalprice+"$");
break;
case 3:
System.out.println("Enter the no of semisters :");
noofsemisters = sc.nextInt();
Totalprice=1500*noofsemisters;
System.out.println("Total price for the plan :"+Totalprice+"$");
break;
case 4:
System.exit(1);
break;
default:
System.out.println("Invalid choice");
break;
}
}
}
output
run:
1. 7 meals per week for $560 per semester
2. 14 meals per week for $1,095 per semester
3. Unlimited meals for $1,500 per semester
4.end the program
enter your selection
2
Enter the no of semisters :
4
Total price for the plan :4380$