Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Name: Brian Everett
- * Email: everetbw@mail.uc.edu
- */
- import java.text.NumberFormat;
- import java.util.Locale;
- import java.util.Scanner;
- public class hw22 {
- public static void main( String[] args ) {
- int menu_choice;
- double price, quantity;
- double sub_total = 0.0;
- //double total = 0.0;
- double Springfield = 1;
- double Shelbyville = 5;
- double Brockway = 2;
- double Ogdenville = 2;
- double North_Haverbrook = 7;
- Scanner scan = new Scanner( System.in );
- do {
- System.out.println( "Add item to order?" );
- System.out.println( "Enter 1 for yes.");
- System.out.println( "Enter 2 for no.");
- menu_choice = scan.nextInt();
- if( menu_choice == 1 ) {
- System.out.println("Enter price");
- double p = scan.nextDouble();
- System.out.println("Enter quantity");
- double q = scan.nextDouble();
- sub_total = sub_total + (p * q);
- }else{
- NumberFormat moneyFormater =
- NumberFormat.getCurrencyInstance(Locale.US);
- System.out.println( "Subtotal:" + moneyFormater.format(sub_total));
- }
- } while( menu_choice != 2 );
- System.out.println("Choose Shipping City");
- System.out.println("1 = Springfield");
- System.out.println("2 = Shelbyville");
- System.out.println("3 = Brockway");
- System.out.println("4 = Ogdenville");
- System.out.println("5 = North Haverbrook");
- NumberFormat moneyFormater =
- NumberFormat.getCurrencyInstance(Locale.US);
- int n = scan.nextInt();
- if(n == 1)
- System.out.println("Total:" + moneyFormater.format(sub_total + Springfield));
- else if(n == 2)
- System.out.println("Total:" + moneyFormater.format(sub_total + Shelbyville));
- else if(n == 3)
- System.out.println("Total:" + moneyFormater.format(sub_total + Brockway));
- else if(n == 4)
- System.out.println("Total:" + moneyFormater.format(sub_total + Ogdenville));
- else if(n == 5)
- System.out.println("Total:" + moneyFormater.format(sub_total + North_Haverbrook));
- else
- System.out.println("Please choose valid city");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement