Hi, I need this source code to be converted to psuecode // import java.util.Date
ID: 3597861 • Letter: H
Question
Hi, I need this source code to be converted to psuecode
//
import java.util.Date;
import java.util.Scanner;
public class GGyros {
Scanner reciept = new Scanner(System.in);
// Methods
public static double calculatingTotal(double sandwhich, double drink, double fries)
{
double TotalCost = sandwhich + drink + fries;
return TotalCost;
}
public static double calculatingTax(double sandwhich, double drink, double fries)
{
double Tax = 0.10;
double TotalCost = sandwhich + drink + fries;
double TotalTax = TotalCost * Tax;
return TotalTax;
}
public static double calculatingGrandTotal(double sandwhich, double drink, double fries)
{
double Tax = 0.10;
double TotalCost = sandwhich + drink + fries;
double TotalTax = TotalCost * Tax;
double GrandTotal = TotalCost + TotalTax;
return GrandTotal;
}
// STUDENT DISCOUNT
public static double calculatingStudentDiscount(double sandwhich, double drink, double fries)
{
double studentDiscount = 0.10;
double TotalCost = sandwhich + drink + fries;
double finalDiscount = TotalCost * studentDiscount;
double finalAmount = TotalCost - finalDiscount;
return finalAmount;
}
// SENIOR CITIZEN DISCOUNT
public static double calculatingSeniorDiscount(double sandwhich, double drink, double fries)
{
double seniorDiscount = 0.20;
double TotalCost = sandwhich + drink + fries;
double finalDiscount = TotalCost * seniorDiscount;
double finalAmount = TotalCost - finalDiscount;
return finalAmount;
}
public static void main(String[]args){
//declaring boolean variables
boolean customerisStudent = true;
boolean customerisaSenior= false;
boolean itscustomersbirthday= false;
boolean noDiscount = true;
//Today's Date and My name
Date todaysDate = new Date();
System.out.println("Nmae: " );
System.out.println("Date:" + todaysDate.toString());
System.out.println("");
//Receipt Header
System.out.println(" ***********************");
System.out.println(" ***Welcome To George's Gyros***");
System.out.println("");
//Menu Array
String sandwichOption [] = {"Gryo's Sandwich","Itailian Beef Sandwich","Hotdog","Hamburger","Free Sandwich"};
double sandwichPrice [] = {5.50, 4.50, 3.80, 3.50, 0.00};
String drinkOption [] = {"Root beer", "Milk", "Cola", "Selter Water"};
double drinkPrice[] = {1.00, 1.00, 1.00, 1.00};
String friesOption [] = {"Greek Fries Large", "Greek Fries Small", "No Greek Fries"};
double friesPrice [] = {1.50, 1.00, 0.00};
//Display Orders
//Customer 1
customerisStudent = true;
customerisaSenior= false;
itscustomersbirthday= false;
String LoganOrder [] = {"Sandwich: " + sandwichOption[0] + " $"+ sandwichPrice[0],
" Drink: " + drinkOption[0] + " $" + drinkPrice[0],
" Fries: "+ friesOption[0] + " $" + friesPrice[0]};
System.out.println("Order 1: Logan");
System.out.println(LoganOrder[0] + LoganOrder[1] + LoganOrder[2]);
System.out.println(" Total Cost: $" + calculatingTotal(sandwichPrice[0],drinkPrice[0], friesPrice[0]));
System.out.println("");
if (customerisStudent == true && itscustomersbirthday == true)
{
System.out.println("Happy Birthday! You get any Sandwich of your choice free today");
System.out.printf(" Grand Total Cost: $%.2f",calculatingTax(sandwichPrice[4],drinkPrice[0], friesPrice[0]) + calculatingStudentDiscount(0,drinkPrice[0], friesPrice[0]));
System.out.println("");
}
if (customerisStudent == true && itscustomersbirthday == false)
{
System.out.println(" Total Cost - Student Discount (10%): $" + calculatingStudentDiscount(sandwichPrice[0],drinkPrice[0], friesPrice[0]));
System.out.println(" Total Tax: $" + calculatingTax(sandwichPrice[0],drinkPrice[0], friesPrice[0]));
System.out.printf (" Grand Total Cost: $%.2f",(calculatingTax(sandwichPrice[0],drinkPrice[0], friesPrice[0]) + calculatingStudentDiscount(sandwichPrice[0],drinkPrice[0], friesPrice[0])));
}
if (noDiscount== true)
{
System.out.println(" Total Tax: $" + calculatingTax(sandwichPrice[0],drinkPrice[0], friesPrice[0]));
System.out.printf (" Grand Total Cost: $%.2f",(calculatingGrandTotal(sandwichPrice[0],drinkPrice[0], friesPrice[0])));
}
double LoganTotal = calculatingTax(sandwichPrice[0],drinkPrice[0], friesPrice[0]) + calculatingStudentDiscount(sandwichPrice[0],drinkPrice[0], friesPrice[0]);
System.out.println("");
//Customer 2
System.out.println("");
customerisStudent = true;
customerisaSenior= false;
itscustomersbirthday= false;
String MatthewOrder [] = {"Sandwich: " + sandwichOption[3] + " $"+ sandwichPrice[3],
" Drink: " + drinkOption[1] + " $" + drinkPrice[1],
" Fries: "+ friesOption[2] + " $" + friesPrice[2]};
System.out.println("Order 2: Matthew");
System.out.println(MatthewOrder[0] + MatthewOrder[1] + MatthewOrder[2]);
System.out.println(" Total Cost: $" + calculatingTotal(sandwichPrice[3],drinkPrice[1], friesPrice[2]));
System.out.println("");
if (customerisStudent == true && itscustomersbirthday == true)
{
System.out.println("Happy Birthday! You get any Sandwich of your choice free today");
System.out.printf(" Grand Total Cost: $%.2f",calculatingTax(sandwichPrice[4],drinkPrice[1], friesPrice[2]) + calculatingStudentDiscount(sandwichPrice[3],drinkPrice[1], friesPrice[2]));
System.out.println("");
}
if (customerisStudent == true && itscustomersbirthday == false)
{
System.out.println(" Total Cost - Student Discount (10%): $" + calculatingStudentDiscount(sandwichPrice[3],drinkPrice[1], friesPrice[2]));
System.out.println(" Total Tax: $" + calculatingTax(sandwichPrice[3],drinkPrice[1], friesPrice[2]));
System.out.printf(" Grand Total Cost: $%.2f",(calculatingTax(sandwichPrice[3],drinkPrice[1], friesPrice[2]) + calculatingStudentDiscount(sandwichPrice[3],drinkPrice[1], friesPrice[2])));
}
if (noDiscount==true)
{
System.out.println(" Total Tax: $" + calculatingTax(sandwichPrice[3],drinkPrice[1], friesPrice[2]));
System.out.printf(" Grand Total Cost: $%.2f",(calculatingGrandTotal(sandwichPrice[3],drinkPrice[1], friesPrice[2])));
}
double MatthewTotal = calculatingTax(sandwichPrice[3],drinkPrice[1], friesPrice[2]) + calculatingStudentDiscount(sandwichPrice[3],drinkPrice[2], friesPrice[2]);
System.out.println("");
//Customer 3
customerisStudent = true;
customerisaSenior= false;
itscustomersbirthday= false;
String SarahOrder [] = {"Sandwich: " + sandwichOption[2] + " $"+ sandwichPrice[2],
" Drink: " + drinkOption[2] + " $" + drinkPrice[2],
" Fries: "+ friesOption[1] + " $" + friesPrice[1]};
System.out.println("Order 3: Sarah");
System.out.println(LoganOrder[0] + LoganOrder[1] + LoganOrder[2]);
System.out.println(" Total Cost: $" + calculatingTotal(sandwichPrice[2],drinkPrice[2], friesPrice[1]));
System.out.println("");
if (customerisStudent == true && itscustomersbirthday == true)
{
System.out.println("Happy Birthday! You get any Sandwich of your choice free today");
System.out.printf(" Grand Total Cost: $%.2f",calculatingTax(sandwichPrice[4],drinkPrice[2], friesPrice[1]) + calculatingStudentDiscount(0,drinkPrice[0], friesPrice[0]));
System.out.println("");
}
if (customerisStudent == true && itscustomersbirthday == false)
{
System.out.println(" Total Cost - Student Discount (10%): $" + calculatingStudentDiscount(sandwichPrice[2],drinkPrice[2], friesPrice[1]));
System.out.println(" Total Tax: $" + calculatingTax(sandwichPrice[2],drinkPrice[2], friesPrice[1]));
System.out.printf(" Grand Total Cost: $%.2f",(calculatingTax(sandwichPrice[2],drinkPrice[2], friesPrice[1]) + calculatingStudentDiscount(sandwichPrice[2],drinkPrice[2], friesPrice[1])));
}
if (noDiscount== true)
{
System.out.println(" Total Tax: $" + calculatingTax(sandwichPrice[2],drinkPrice[2], friesPrice[1]));
System.out.printf(" Grand Total Cost: $%.2f",(calculatingGrandTotal(sandwichPrice[2],drinkPrice[2], friesPrice[1])));
}
double SarahTotal = calculatingTax(sandwichPrice[2],drinkPrice[2], friesPrice[1]) + calculatingStudentDiscount(sandwichPrice[2],drinkPrice[2], friesPrice[1]);
System.out.println("");
// Order 4
System.out.println("");
customerisStudent = true;
customerisaSenior= false;
itscustomersbirthday= true;
String AllisonOrder [] = {"Sandwich: Italian Beef: " + sandwichOption[4] + " $"+ sandwichPrice[4],
" Drink: " + drinkOption[3] + " $" + drinkPrice[3],
" Fries: "+ friesOption[2] + " $" + friesPrice[2]};
System.out.println("Order 4: Allison");
System.out.println(AllisonOrder[0] + AllisonOrder[1] + AllisonOrder[2]);
System.out.println(" Total Cost: $" + calculatingTotal(sandwichPrice[4],drinkPrice[3], friesPrice[2]));
System.out.println("");
if (customerisStudent == true && itscustomersbirthday == true)
{
System.out.println("Happy Birthday! You get any Sandwich of your choice free today");
System.out.printf(" Grand Total Cost: $%.2f",calculatingTax(sandwichPrice[4],drinkPrice[3], friesPrice[2]) + calculatingStudentDiscount(sandwichPrice[4],drinkPrice[3], friesPrice[2]));
System.out.println("");
}
if (customerisStudent == true && itscustomersbirthday == false)
{
System.out.println(" Total Cost - Student Discount (10%): $" + calculatingStudentDiscount(sandwichPrice[1],drinkPrice[3], friesPrice[2]));
System.out.println(" Total Tax: $" + calculatingTax(sandwichPrice[1],drinkPrice[3], friesPrice[2]));
System.out.printf(" Grand Total Cost: $%.2f",(calculatingTax(sandwichPrice[1],drinkPrice[3], friesPrice[2]) + calculatingStudentDiscount(sandwichPrice[1],drinkPrice[3], friesPrice[2])));
}
if (noDiscount== true)
{
System.out.println(" Total Tax: $" + calculatingTax(sandwichPrice[1],drinkPrice[3], friesPrice[2]));
System.out.printf(" Grand Total Cost: $%.2f",(calculatingGrandTotal(sandwichPrice[1],drinkPrice[3], friesPrice[2])));
}
double BirthdayAllisonTotal = calculatingTax(sandwichPrice[4],drinkPrice[3], friesPrice[2]) + calculatingStudentDiscount(sandwichPrice[4],drinkPrice[3], friesPrice[2]);
System.out.println("");
//My Order
//Customer 1
customerisStudent = true;
customerisaSenior= false;
itscustomersbirthday= false;
String NikkieOrder [] = {"Sandwich: " + sandwichOption[0] + " $"+ sandwichPrice[0],
" Drink: " + drinkOption[0] + " $" + drinkPrice[0],
" Fries: "+ friesOption[0] + " $" + friesPrice[0]};
System.out.println("");
System.out.println("Order 5: Nikkie");
System.out.println(NikkieOrder[0] + NikkieOrder[1] + NikkieOrder[2]);
System.out.println(" Total Cost: $" + calculatingTotal(sandwichPrice[0],drinkPrice[0], friesPrice[0]));
System.out.println("");
if (customerisStudent == true && itscustomersbirthday == true)
{
System.out.println("Happy Birthday! You get any Sandwich of your choice free today");
System.out.printf(" Grand Total Cost: $%.2f",calculatingTax(sandwichPrice[4],drinkPrice[0], friesPrice[0]) + calculatingStudentDiscount(0,drinkPrice[0], friesPrice[0]));
System.out.println("");
}
if (customerisStudent == true && itscustomersbirthday == false)
{
System.out.println(" Total Cost - Student Discount (10%): $" + calculatingStudentDiscount(sandwichPrice[0],drinkPrice[0], friesPrice[0]));
System.out.println(" Total Tax: $" + calculatingTax(sandwichPrice[0],drinkPrice[0], friesPrice[0]));
System.out.printf (" Grand Total Cost: $%.2f",(calculatingTax(sandwichPrice[0],drinkPrice[0], friesPrice[0]) + calculatingStudentDiscount(sandwichPrice[0],drinkPrice[0], friesPrice[0])));
}
if (noDiscount== true)
{
System.out.println(" Total Tax: $" + calculatingTax(sandwichPrice[0],drinkPrice[0], friesPrice[0]));
System.out.printf (" Grand Total Cost: $%.2f",(calculatingGrandTotal(sandwichPrice[0],drinkPrice[0], friesPrice[0])));
}
double NikkieTotal = calculatingTax(sandwichPrice[0],drinkPrice[0], friesPrice[0]) + calculatingStudentDiscount(sandwichPrice[0],drinkPrice[0], friesPrice[0]);
System.out.println("");
System.out.println("");
//
System.out.println("");
// Displaying the FINAL cost
System.out.printf(" Grand Total Cost: $%.2f", LoganTotal + MatthewTotal + SarahTotal + BirthdayAllisonTotal + NikkieTotal);
//
// Program Footer
System.out.println("");
System.out.println("************************************");
System.out.println("****Thanks for patronizing us****");
System.out.println("************************************");
}
}
Explanation / Answer
Psuecode:
class GGyro:
calculatingTotal():
adds all input costs for sandwitch, drink and fries and returns resulted total cost.
calculatingTax():
finds total cost from costs of sandwitch, drink and fries. Then applys 10% tax rate on total cost and returns the tax amount.
calculatingGrandTotal():
finds total amount and tax amount, then adds them up and returns as grand total.
calculatingStudentDiscount():
finds total amount and applys 10% student discount rate on total amount then subtracts discount amount from total amount and returns resulted discounted cost.
calculatingSeniorDiscount():
finds total amount and applys 20% senior citizen discount rate on total amount then subtracts discount amount from total amount and returns resulted discounted cost.
main():
Initialize necessary variables.
Print(name)
Print(todays date)
Print(program header)
//hardcore all possible values. Initialize possible sandwich, drink and fries names and their prices
//Regarding customer 1 -> Logan who is a student.
Prepare some random order(select sandwich, drink and fries)
Print(total amount of that order)
Define code for if customer is student and his/her birthday is today:
Print(wish him/her with birthday wishes)
Print(calculatingTax + calculatingStudentDiscount)
Define code for if customer is student and his/her birthday is not today:
Print(calculatingStudentDiscount and calculatingTax)
Print(calculatingTax + calculatingStudentDiscount)
Define code for if customer has no discount:
Print(calculatingTax)
Print(calculatingGrandTotal)
findTotalForThatCustomer = calculatingTax + calculatingStudentDiscount
Repeat above code for next 4 orders of Mathew, Sarah, Allison whose birthday is today and Nikkie
Print(whole total of all 5 customers)
Print(program footer)
Thanks for waiting
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.