Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions