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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!