0% found this document useful (0 votes)
21 views9 pages

Week 10 Activity

The document contains source code for two Java programs. The first program uses a switch statement to output a grade based on a user's score. The second program is a restaurant ordering system that uses switch statements to determine meal and drink prices based on user input and calculates a total cost.

Uploaded by

juencyzalty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views9 pages

Week 10 Activity

The document contains source code for two Java programs. The first program uses a switch statement to output a grade based on a user's score. The second program is a restaurant ordering system that uses switch statements to determine meal and drink prices based on user input and calculates a total cost.

Uploaded by

juencyzalty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Dela Cruz, Franc Alvenn T.

BSIT – 1A

Week 10 Activity

//Number 1 (Source Code)

package itpacts;
import java.io.*;
public class Week10 {

public static void main(String[] args)throws IOException {


BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
int score;
//program start
System.out.print("Please enter you score: ");
score = Integer.parseInt(input.readLine());
switch(score){
case 90,91,92,93,94,95,96,97,98,99,100:
System.out.println("Your score is: " + score);
System.out.println("Value Grade: A");
break;
case 80,81,82,83,84,85,86,87,88,89:
System.out.println("Your score is: " + score);
System.out.println("Value Grade: B");
break;
case 70,71,72,73,74,75,76,77,78,79:
System.out.println("Your score is: " + score);
System.out.println("Value Grade: C");
break;
case 60,61,62,63,64,65,66,67,68,69:
System.out.println("Your score is: " + score);
System.out.println("Value Grade: D");
break;
default:
if(score < 60){
System.out.println("Your score is: " + score);
System.out.println("Value Grade: E");
}else{
System.out.println("The score: " + score + " is not valid.");
}
break;
}
}
}
//Number 2 (Source Code)

package itpacts;
import java.io.*;
public class Week10 {

public static void main(String[] args)throws IOException {


BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
String meal = "";
String drinkSize = "";
String mealPackage = "";
int mealPrice = 0;
int drinkPrice=0;
int quantity = 0;
int totalAmount=0;

System.out.println("Welcome to Restaurant Paradise");


System.out.println("Here is the menu");
System.out.println(" Meal | Package | Price ");
System.out.println("--------+-------------------------+--------");
System.out.println(" A | Chicken & Spaghetti | 160 ");
System.out.println(" B | Burger & Fries | 120 ");
System.out.println(" C | Cheesedog | 100 ");
System.out.println(" D | Palabok | 90 ");
System.out.println("--------+-------------------------+--------");
System.out.println(" Drinks | Price ");
System.out.println("--------+-------------------------+--------");
System.out.println(" S + 35");
System.out.println(" M + 45");
System.out.println(" L + 55");
System.out.println("-------------------------------------------");
System.out.print("What would you like to order: ");
meal = input.readLine();
System.out.print("What size of drinks would you like: ");
drinkSize = input.readLine();
System.out.print("How many servings would you like: ");
quantity = Integer.parseInt(input.readLine());

switch(meal){
case "A","a":
mealPackage = "Chicken & Spaghetti";
mealPrice = 160;
switch(drinkSize){
case "S","s":
drinkPrice = 35;
break;
case "M","m":
drinkPrice = 45;
break;
case "L","l":
drinkPrice = 55;
break;
default:
System.out.println("Invalid Input");
break;
}
break;
case "B","b":
mealPackage = "Burger & Fries";
mealPrice = 120;
switch(drinkSize){
case "S","s":
drinkPrice = 35;
break;
case "M","m":
drinkPrice = 45;
break;
case "L","l":
drinkPrice = 55;
break;
default:
System.out.println("Invalid Input");
break;
}
break;
case "C","c":
mealPackage = "Cheesedog";
mealPrice = 100;
switch(drinkSize){
case "S","s":
drinkPrice = 35;
break;
case "M","m":
drinkPrice = 45;
break;
case "L","l":
drinkPrice = 55;
break;
default:
System.out.println("Invalid Input");
break;
}
break;
case "D","d":
mealPackage = "Palabok";
mealPrice = 90;
switch(drinkSize){
case "S","s":
drinkPrice = 35;
break;
case "M","m":
drinkPrice = 45;
break;
case "L","l":
drinkPrice = 55;
break;
default:
System.out.println("Invalid Input");
break;
}
break;
default:
System.out.println("Invalid Input");
break;
}

totalAmount = (mealPrice + drinkPrice)*quantity;

System.out.println("-------------------------------------------");
System.out.println("Your order is: " + meal + " - " + mealPackage);
System.out.println("Drinks Size is: " + drinkSize);
System.out.println("Servings: " + quantity);
System.out.println("Your total is: " + totalAmount);
System.out.println("-------------------------------------------");
System.out.println("Thank you for eating at Restaurant Paradise");
}
}

You might also like