Advertisement
Guest User

Untitled

a guest
May 19th, 2017
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.57 KB | None | 0 0
  1. /*
  2.  * Name: Brian Everett
  3.  * Email: everetbw@mail.uc.edu
  4.  */
  5. import java.text.NumberFormat;
  6. import java.util.Locale;
  7. import java.util.Scanner;
  8.  
  9. public class hw22 {
  10.    
  11.     public static void main( String[] args ) {
  12.         int menu_choice;
  13.         double price, quantity;
  14.         double sub_total = 0.0;                
  15.         //double total = 0.0;
  16.         double Springfield = 1;
  17.         double Shelbyville = 5;
  18.         double Brockway = 2;
  19.         double Ogdenville = 2;
  20.         double North_Haverbrook = 7;
  21.         Scanner scan = new Scanner( System.in );
  22.        
  23.  
  24.         do {
  25.             System.out.println( "Add item to order?" );
  26.             System.out.println( "Enter 1 for yes.");
  27.             System.out.println( "Enter 2 for no.");
  28.            
  29.  
  30.             menu_choice = scan.nextInt();
  31.  
  32.             if( menu_choice == 1 ) {
  33.                
  34.                 System.out.println("Enter price");
  35.                 double p = scan.nextDouble();
  36.                 System.out.println("Enter quantity");
  37.                 double q = scan.nextDouble();
  38.                 sub_total = sub_total + (p * q);
  39.                
  40.                
  41.                
  42.             }else{
  43.                 NumberFormat moneyFormater =
  44.                     NumberFormat.getCurrencyInstance(Locale.US);
  45.                 System.out.println( "Subtotal:" + moneyFormater.format(sub_total));
  46.                
  47.                
  48.                
  49.                
  50.                
  51.             }
  52.         } while( menu_choice != 2  );          
  53.        
  54.         System.out.println("Choose Shipping City");
  55.         System.out.println("1 = Springfield");
  56.         System.out.println("2 = Shelbyville");
  57.         System.out.println("3 = Brockway");
  58.         System.out.println("4 = Ogdenville");
  59.         System.out.println("5 = North Haverbrook");
  60.        
  61.         NumberFormat moneyFormater =
  62.             NumberFormat.getCurrencyInstance(Locale.US);
  63.        
  64.         int n = scan.nextInt();
  65.         if(n == 1)
  66.             System.out.println("Total:" + moneyFormater.format(sub_total + Springfield));
  67.         else if(n == 2)
  68.             System.out.println("Total:" + moneyFormater.format(sub_total + Shelbyville));
  69.         else if(n == 3)
  70.             System.out.println("Total:" + moneyFormater.format(sub_total + Brockway));
  71.         else if(n == 4)
  72.             System.out.println("Total:" + moneyFormater.format(sub_total + Ogdenville));
  73.         else if(n == 5)
  74.             System.out.println("Total:" + moneyFormater.format(sub_total + North_Haverbrook));
  75.     else
  76.             System.out.println("Please choose valid city");
  77.            
  78.        
  79.  
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement