Question
Describe the functionality of the following code in one paragraph // A JAVA Program import java.util.*; class Application{ // main method public static void main(String
Describe the functionality of the following code in one paragraph
// A JAVA Program
import java.util.*;
class Application{
// main method
public static void main(String arg[]){
Scanner scan = new Scanner(System.in);
String ownerName = "Amit";
// now when user comes
// ask name
System.out.print("Welcome! Please enter your name ");
String name = scan.nextLine();
// now ask the size of pizza
double priceSmall = 100;
double priceMedium = 200;
double priceLarge = 300;
int pizzaChoice;
System.out.print("Enter the choice 1.Small Pizza 2.Medium Pizza 3.Large Pizza ");
pizzaChoice = scan.nextInt();
int crust;
System.out.print("Do you want crust 1.YES 2.NO ");
crust = scan.nextInt();
int topping;
System.out.print("Do you want topping 1.YES 2.NO ");
topping = scan.nextInt();
double Cost = 0.0;
switch (pizzaChoice) {
case 1:
Cost += 100;
break;
case 2:
Cost += 200;
break;
default:
Cost += 300;
break;
}
if(crust == 1){
Cost += 40;// crust cost =40
}
if(topping == 1){
Cost += 50;// topping cost = 50
}
System.out.println("Total = "+Cost);
double discount=0;
if(ownerName.equals(name.split(" ")[0])){
discount = 10;
}
System.out.println("Discount = "+discount);
System.out.println("Cost = "+(Cost-discount));
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started