Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class InvoiceApp
  4. {
  5. public static void main(String[] args)
  6. {
  7. //Declare variables and Scanner object
  8. Scanner input = new Scanner(System.in);
  9. double discountpercent; //stores discount percent
  10. double discountamount; //stores discount amount
  11. double amount; //stores amount interger
  12. double total; //stores total amount
  13. double subtotal = 0; //stores subtotal amount
  14. int number; //number
  15.  
  16.  
  17. //Display a welcome message
  18. System.out.println("*****************************************************");
  19. System.out.println("\tWelcome to the Invoice Total Calculator");
  20. System.out.println("*****************************************************");
  21.  
  22. //Prompt user for customer type
  23. System.out.print("Enter customer type (as an interger): ");
  24.  
  25. //Read customer type
  26. number = input.nextInt();
  27.  
  28. switch(number){
  29.  
  30. case 1:
  31. if(subtotal >=500) {
  32. discountpercent = 0.20;
  33.  
  34. }
  35. else if(subtotal < 500 && subtotal >= 250) {
  36. discountpercent = 0.15;
  37.  
  38. }
  39. else if(subtotal < 250 && subtotal >= 100){
  40. discountpercent = 0.10;
  41.  
  42. }
  43. else
  44. discountpercent = 0.00;
  45.  
  46. break;
  47.  
  48.  
  49. case 2: discountpercent = 0.20; break;
  50.  
  51. case 3:
  52. if(subtotal >=500) {
  53. discountpercent = 0.50;
  54. }
  55. else
  56. discountpercent = 0.40; break;
  57.  
  58. default:
  59. discountpercent = 0.05;
  60. }//end of switch
  61.  
  62. //Prompt user for subtotal
  63. System.out.print("Enter Subtotal: ");
  64.  
  65. //Read subtotal
  66. subtotal = input.nextInt();
  67.  
  68. //Calculate Discount Rate
  69. discountamount = (subtotal * discountpercent);
  70.  
  71. //Calculate Invoice Total
  72. total = (subtotal - discountamount);
  73.  
  74. //Display thank you message
  75. System.out.println("*****************************************************");
  76. System.out.println("\t\tINVOICE REPORT");
  77. System.out.println("\tSubtotal: \t\t" + subtotal);
  78. System.out.println("\tCustomer type: \t\t" + number);
  79. System.out.println("\tDiscount percent: \t" + discountpercent);
  80. System.out.println("\tDiscount amount: \t" + discountamount);
  81. System.out.println("\tTotal: \t\t" + total);
  82. System.out.println("\t\t Thank you!!");
  83. System.out.println("*****************************************************");
  84.  
  85. //Format and display the results
  86.  
  87.  
  88.  
  89. }//end of main
  90. }//end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement