PizzaOrder.java
/*
* PizzaOrder.java
*/
import java.util.*;
/**
* Pizza Order
*
* orders a pizza <br>
* and print out the price.
*
*
* @author Timothy Nguyen
* @version 1.0
*
* Compiler: Java 1.6 <br>
* Hardware: PC <br>
*
* April 10, 2008 <br>
* TN completed v 1.0
* April 17, 2008 <br>
* Add on toppings v 1.01
* April 23, 2008 <br>
* add if statments and fix errors v 1.02
* April 24, 2008 <br>
* adding outputs and almost finish project v 1.03
* TN completed v 1.04
*/
public class PizzaOrder
{
public static final int SMALL_DIAMETER = 10;
public static final int MEDIUM_DIAMETER = 13;
public static final int LARGE_DIAMETER = 16;
public static final double TOPPINGS = .90;
public static final double Tax = .089;
public static final double PI = 3.14 ;
/**
* orders a pizza<br>
* input: size and # of toppings from keyboard<br>
* output: orders your pizza<br>
* @param args command-line arguments
*/
public static void main(String[] args)
{
int numberOfToppings = 0;
double radius = 6.5;
double area = 0.0;
double sizeInInches = 0;
double price = 0.0;
String size = "S";
Scanner in = new Scanner(System.in);
System.out.println("Enter the size of the pizza you want(S|M|L): " wink ;
size = in.next();
size = size.trim().substring(0, 1).toUpperCase();
if(size.equals("M" wink )
{
sizeInInches = MEDIUM_DIAMETER;
}
else if(size.equals("L" wink )
{
sizeInInches = LARGE_DIAMETER;
}
else
{
size = "S";
sizeInInches = SMALL_DIAMETER;
}
System.out.println("Pizza Size = " + size);
System.out.println("Enter how many toppings <0 - 8>: " wink ;
if(in.hasNextInt())
numberOfToppings = in.nextInt();
if(numberOfToppings < 0)
numberOfToppings = 0 ;
if(numberOfToppings > cool
numberOfToppings = 8 ;
System.out.println("toppings = "+ numberOfToppings);
radius = sizeInInches/2;
area = Math.PI * (radius * radius);
System.out.println("Pizza Size = " + radius + " inches: " +
"has an area of " +area+ " square inches" wink ;
price = sizeInInches + TOPPINGS * numberOfToppings;
System.out.println("Price = " + price);
System.out.println("Tax = " + price * Tax);
System.out.println("Total Price = " + price + (price * Tax) );
System.out.println("Price in Sq inches = " + (price / area) );
}
}
View User's Journal
TimmyAzai's Memories
Well I like to talk about anything, stories, papers, current news.