0% found this document useful (0 votes)
51 views5 pages

Args /: @param

The document contains code for two Java programs that calculate discounts, totals, and change for purchases. The first program allows a user to enter their status and calculates the discounted price and change based on different discount rates for different statuses. The second program allows a user to select a meal and drink, enter quantities and payment, and calculates subtotals, total, and change. It uses switch statements to calculate prices and totals based on the user's meal and drink selections.

Uploaded by

MelodyZafeII
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)
51 views5 pages

Args /: @param

The document contains code for two Java programs that calculate discounts, totals, and change for purchases. The first program allows a user to enter their status and calculates the discounted price and change based on different discount rates for different statuses. The second program allows a user to select a meal and drink, enter quantities and payment, and calculates subtotals, total, and change. It uses switch statements to calculate prices and totals based on the user's meal and drink selections.

Uploaded by

MelodyZafeII
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/ 5

import java.util.

Scanner;
public class Quiz1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
while (true){
Scanner in = new Scanner(System.in);

double Price, DPrice, Dis, Cash, Change;

System.out.println("Status!");
System.out.println("Regular, PWD, S.Citizen");
System.out.println("VIP = Gold, Silver");
System.out.print("Enter Status: ");
String stats = in.nextLine();
System.out.print("Enter Payment/Cash: ");
Cash = in.nextInt();
System.out.print("Enter Price: ");
Price = in.nextInt();
System.out.println("");
System.out.println("BILL:");

if (stats.equals("Regular")){
System.out.println("Regular");
Dis = (Price * .0);
System.out.println("Discount:" + Dis);
DPrice = (Price - Dis);
System.out.println("Discounted Price:" + DPrice);
Change = (Cash - DPrice);
System.out.println("Change: " + Change);}
else if (stats.equals("PWD")){
System.out.println("PWD");
Dis = (Price * .10);
System.out.println("Discount:" + Dis);
DPrice = (Price - Dis);
System.out.println("Discounted Price:" + DPrice);
Change = (Cash - DPrice);
System.out.println("Change: " + Change);}
else if (stats.equals("S.Citizen")){
System.out.println("S.Citizen");
Dis = (Price * .10);
System.out.println("Discount:" + Dis);
DPrice = (Price - Dis);
System.out.println("Discounted Price:" + DPrice);
Change = (Cash - DPrice);
System.out.println("Change: " + Change);}
else if (stats.equals("Gold")){
System.out.println("Gold");
Dis = (Price * .30);
System.out.println("Discount:" + Dis);
DPrice = (Price - Dis);
System.out.println("Discounted Price:" + DPrice);
Change = (Cash - DPrice);
System.out.println("Change: " + Change);}
else if (stats.equals("Silver")){
System.out.println("Silver");
Dis = (Price * .20);
System.out.println("Discount:" + Dis);
DPrice = (Price - Dis);
System.out.println("Discounted Price:" + DPrice);
Change = (Cash - DPrice);
System.out.println("Change: " + Change);}
}
}
}
import java.util.Scanner;
public class Quiz2 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);

int Total, Change, TMeal = 0, TDrinks;

System.out.println("Meals!");
System.out.println("A Spaghetti and Burger P.120");
System.out.println("B Burger and Fries P.150");
System.out.println("C Spaghetti and Fries P.130");
System.out.println("D Spaghetti and Chicken P.110");
System.out.println("Drinks!");
System.out.println("S Small P.30");
System.out.println("M Small P.40");
System.out.println("L Small P.50");
System.out.println("");
System.out.print("What is your Meal?: ");
char Meal = in.nextLine().charAt(0);
System.out.print("What is your Drink?: ");
char Drinks = in.nextLine().charAt(0);
System.out.print("How many?: ");
int Quantity = in.nextInt();
System.out.print("Payment/Cash: ");
int Payment = in.nextInt();

System.out.println("");
System.out.println("Receipt:");
switch(Meal){
case 'A':
System.out.println("Meal: A");
System.out.println("Price: 120");
System.out.println("Quantity: " + Quantity);
System.out.println("Payment/Cash: " + Payment);
TMeal = (Quantity * 120);
System.out.println("Total Meal/s: " + TMeal);
break;
case 'B':
System.out.println("Meal: B");
System.out.println("Price: 150");
System.out.println("Quantity: " + Quantity);
System.out.println("Payment/Cash: " + Payment);
TMeal = (Quantity * 150);
System.out.println("Total Meal/s: " + TMeal);
break;
case 'C':
System.out.println("Meal: C");
System.out.println("Price: 130");
System.out.println("Quantity: " + Quantity);
System.out.println("Payment/Cash: " + Payment);
TMeal = (Quantity * 130);
System.out.println("Total Meal/s: " + TMeal);
break;
case 'D':
System.out.println("Meal: D");
System.out.println("Price: 110");
System.out.println("Quantity: " + Quantity);
System.out.println("Payment/Cash: " + Payment);
TMeal = (Quantity * 110);
System.out.println("Total Meal/s: " + TMeal);
break;
}
switch(Drinks){
case 'S':
System.out.println("Drink: S");
System.out.println("Price: 30");
TDrinks = (Quantity * 30);
System.out.println("Total Drink/s: " + TDrinks);
Total = (TMeal + TDrinks);
System.out.println("Total Price: " + Total);
Change = (Payment - Total);
System.out.println("Change: " + Change);
break;
case 'M':
System.out.println("Drink: M");
System.out.println("Price: 40");
TDrinks = (Quantity * 40);
System.out.println("Total Drink/s: " + TDrinks);
Total = (TMeal + TDrinks);
System.out.println("Total Price: " + Total);
Change = (Payment - Total);
System.out.println("Change: " + Change);
break;
case 'L':
System.out.println("Drink: L");
System.out.println("Price: 50");
TDrinks = (Quantity * 50);
System.out.println("Total Drink/s: " + TDrinks);
Total = (TMeal + TDrinks);
System.out.println("Total Price: " + Total);
Change = (Payment - Total);
System.out.println("Change: " + Change);
break;

}
}

You might also like