0% found this document useful (0 votes)
84 views6 pages

JAVA

The document contains code for a McDonald's ordering program with the following functionality: 1. It defines methods for displaying the menu options, calculating prices for a Big Mac meal with options to supersize sides, and getting user input. 2. The main method displays the menu, gets a user selection, calls the appropriate method to handle that item's order, and calculates a running total. 3. The program allows a user to order items from the McDonald's menu, customize their order with options like supersizing, and displays the final total cost.
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)
84 views6 pages

JAVA

The document contains code for a McDonald's ordering program with the following functionality: 1. It defines methods for displaying the menu options, calculating prices for a Big Mac meal with options to supersize sides, and getting user input. 2. The main method displays the menu, gets a user selection, calls the appropriate method to handle that item's order, and calculates a running total. 3. The program allows a user to order items from the McDonald's menu, customize their order with options like supersizing, and displays the final total cost.
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/ 6

MACDO

import java.util.Scanner;

public class Methods {

public static void menu (){


System.out.println("1. Big Mac Meal - $6.48");
System.out.println("2. Fish o Filet Meal - $6.88");
System.out.println("3. Chicken Nugget Meal - $6.52");
System.out.println("4. Hamburger Meal - $3.78\n");
}
public static void bigMacMeal(Scanner scan, double superFries,
double superDrink){
String userInput;
double price = 6.48;
double priceF = 6.48 + superFries;
double priceD = 6.48 + superDrink;
double priceB = 6.48 + superFries + superDrink;
System.out.println("Would you like to super size
your meal?(Yes/No)\n");
userInput = scan.next();
if (userInput == "Yes"){
price = priceF;
}else{
price = price;
}
System.out.println("Would you like to super size
your drink?(Y/N)\n");
userInput = scan.next();
if (userInput == "Yes" && price > 7){
price = priceB;
}
if (userInput == "Yes"){
price = priceD;
}
if (price = true){

}
System.out.println("Your total is: $" + price);
}
public static void fishFilet(){

}
public static void chickenNugget(){

}
public static void hamburgerMeal(){

}
public static void main(String[] args){
Scanner scan = new Scanner (System.in);

System.out.println("Welcome to Mcdonalds!\n");
menu();
System.out.println("What would you like from the menu?(1 -
4)\n");
int userInput = scan.nextInt();
if (userInput == 1){
bigMacMeal(scan, userInput, userInput);
}
if (userInput == 2){
fishFilet();
}
if (userInput == 3){
chickenNugget();
}
if (userInput == 4){
hamburgerMeal();
}
double bigMac = 3.49;
double fishFil = 3.89;
double hamburger = .79;
double chickenNuggets = 3.53;
double fries = 1.89;
double superFries = 2.89;
double drink = 1.10;
double superDrink = 2.52;
double tax = .065;
}
}
ORDINARY FAST FOOD

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

package javaapplication22;

/**

* @author Student

*/

import java.util.Scanner;

public class JavaApplication22 {

public double subTotal;

public static double runningTotal;

private static double itemPrice;

static boolean ordering = true;

static Scanner input = new Scanner(System.in);

public static void menu() {

System.out.println("Welcome \n1. Burger (Php 50.00 ) \n2. Fries (Php 45.00 )\n3. Soda (Php 20.00)
\n4. Done");

public static double itemPrice(int foodItem) {

if (foodItem == 1) {

// burger= Php 50.00


System.out.println("You've ordered a burger");

itemPrice = 50.00;

if (foodItem == 2) {

// fries = Php 45.00

System.out.println("You've ordered fries");

itemPrice = 45.00;

if (foodItem == 3) {

// soda = Php 20.00

System.out.println("You've ordered a soda");

itemPrice = 20.100;

quantity();

return itemPrice;

public static double quantity() {

System.out.println("Enter quantity");

double quantity = input.nextDouble();

subTotal(quantity, itemPrice);

return quantity;

public static double subTotal(double quantity, double itemPrice) {

double subTotal = quantity * itemPrice;

System.out.println("Subtotal: " + subTotal);

return subTotal;

}
public static void done(double runningTotal) {

ordering = false;

System.out.println(runningTotal);

System.out.println("Enjoy your meal");

public static void main(String[] args) {

int menuOption;

int foodItem = 0;

input = new Scanner(System.in);

do {

double runningTotal = 0;

menu();

menuOption = input.nextInt();

switch (menuOption) {

case 1:

foodItem = 1;

itemPrice(foodItem);

break;

case 2:

foodItem = 2;

itemPrice(foodItem);

break;

case 3:

foodItem = 3;

itemPrice(foodItem);

break;

case 4:
done(runningTotal);

break;

default:

System.out.println("Invalid option.");

} while (ordering);

subTotal(quantity(), itemPrice(foodItem));

runningTotal = runningTotal + subTotal(quantity(), itemPrice(foodItem));

You might also like