Kulas_Code20

Bianca

Nov 9th, 2021 (edited)
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.64 KB | None | 0 0
  1. import java.util.*;
  2. import java.text.DecimalFormat;
  3.  
  4. public class Main //Bianca
  5. {
  6.     public static void main(String args[]) {
  7.         Scanner sc = new Scanner(System.in);
  8.         DecimalFormat df = new DecimalFormat("###,###.00");
  9.         //Variable declaration
  10.         String product1, product2, product3, productName = "";
  11.         double price1, price2, price3, total_int, total_Amount,
  12.         monnthly_Amortization;
  13.         double cash_dis, threeMon_interest, sixMon_interest, twelveMon_interest,
  14.         productPrice = 0;
  15.  
  16.         System.out.println("Sales Input:\n");
  17.         System.out.print("Enter Product 1:  ");
  18.         product1 = sc.nextLine();
  19.         System.out.print("Enter Price:      $");
  20.         price1 = sc.nextDouble();
  21.         sc.nextLine();
  22.         System.out.print("\nEnter Product 2:    ");
  23.         product2 = sc.nextLine();
  24.         System.out.print("Enter Price:      $");
  25.         price2 = sc.nextDouble();
  26.         sc.nextLine();
  27.         System.out.print("\nEnter Product 3:    ");
  28.         product3 = sc.nextLine();
  29.         System.out.print("Enter Price:      $");
  30.         price3 = sc.nextDouble();
  31.  
  32.         System.out.println("Input Mode of Payment Terms:\n");
  33.         System.out.print("Cash Discount: ");
  34.         cash_dis = sc.nextInt();
  35.         System.out.println("You input " + (int) cash_dis +
  36.             "% Discount for Cash\n");
  37.         System.out.print("3 Months Installment: ");
  38.         threeMon_interest = sc.nextInt();
  39.         System.out.println("You input " + (int) threeMon_interest +
  40.             "% Interest for 3 Months Installment\n");
  41.         System.out.print("6 Months Installment: ");
  42.         sixMon_interest = sc.nextInt();
  43.         System.out.println("You input " + (int) sixMon_interest +
  44.             "% Interest for 6 Months Installment\n");
  45.         System.out.print("12 Months Installment: ");
  46.         twelveMon_interest = sc.nextInt();
  47.         System.out.println("You input " + (int) twelveMon_interest +
  48.             "% Interest for 12 Months Installment\n");
  49.  
  50.         System.out.println("Main Menu\n\n");
  51.         char p1 = product1.charAt(0);
  52.         char p2 = product2.charAt(0);
  53.         char p3 = product3.charAt(0);
  54.         char c1 = Character.toLowerCase(p1);
  55.         char c2 = Character.toLowerCase(p2);
  56.         char c3 = Character.toLowerCase(p3);
  57.  
  58.         System.out.print("\nPress "+p1+"/"+c1+"\t\t"+product1+"   "+df.format(price1));
  59.         System.out.print("\nPress "+p2+"/"+c2+"\t"+product2+"   "+df.format(price2));
  60.         System.out.print("\nPress "+p3+"/"+c3+"\t"+product3+"   "+df.format(price3));
  61.         System.out.print("\nEnter Item: ");
  62.         char item = sc.next().charAt(0);
  63.         item = Character.toLowerCase(item);
  64.  
  65.         //first switch
  66.         switch (item) {
  67.         case 'i':
  68.             System.out.println("Your Item is " + product1 + "\nPrice:\t\t$" +
  69.                 df.format(price1));
  70.             productName = product1;
  71.             productPrice = price1;
  72.             break;
  73.         case 's':
  74.             System.out.println("Your Item is " + product2 +
  75.                 "\nPrice:\t\t$" + df.format(price2));
  76.             productName = product2;
  77.             productPrice = price2;
  78.             break;
  79.         case 'x':
  80.             System.out.println("Your Item is " + product3 +
  81.                 "\nPrice:\t\t$" + df.format(price3));
  82.             productName = product3;
  83.             productPrice = price3;
  84.             break;
  85.         default:
  86.             System.out.println("Invalid input!");
  87.         }
  88.  
  89.         System.out.println("\nSelect Mode of Payment\n");
  90.         System.out.println("Press 1: Cash                   " + (int) cash_dis +
  91.             "% Discount");
  92.         System.out.println("Press 2: 3 Months Installment   " +
  93.             (int) threeMon_interest + "% Interest");
  94.         System.out.println("Press 3: 6 Months Installment   " +
  95.             (int) sixMon_interest + "% Interest");
  96.         System.out.println("Press 4: 12 Months Installment  " +
  97.             (int) twelveMon_interest + "% Interest");
  98.         System.out.print("\nEnter Mode of Payment: ");
  99.         int pmode = sc.nextInt();
  100.  
  101.         //2nd switch
  102.         switch (pmode) {
  103.         case 1:
  104.             total_int = productPrice * (cash_dis / 100);
  105.             total_Amount = productPrice - total_int;
  106.             System.out.println("Mode of Payment: Cash");
  107.             System.out.println("Item: " + productName);
  108.             System.out.printf("Price: " + df.format(productPrice));
  109.             System.out.printf("Discount/Interest: " + df.format(total_int));
  110.             System.out.printf("Total Amount: " + df.format(total_Amount));
  111.             break;
  112.         case 2:
  113.             total_int = productPrice * (threeMon_interest / 100);
  114.             total_Amount = productPrice + total_int;
  115.             monnthly_Amortization = total_Amount / 3;
  116.             System.out.println("Mode of Payment: 3 Months Installment");
  117.             System.out.println("Item: " + productName);
  118.             System.out.printf("Price: " + df.format(productPrice));
  119.             System.out.printf("Discount/Interest: " + df.format(total_int));
  120.             System.out.printf("Total Amount: " + df.format(total_Amount));
  121.             System.out.printf("Monthly Amortization: " + df.format(monnthly_Amortization));
  122.             break;
  123.         case 3:
  124.             total_int = productPrice * (sixMon_interest / 100);
  125.             total_Amount = productPrice + total_int;
  126.             monnthly_Amortization = total_Amount / 6;
  127.             System.out.println("Mode of Payment: 6 Months Installment");
  128.             System.out.println("Item: " + productName);
  129.             System.out.printf("Price: " + df.format(productPrice));
  130.             System.out.printf("Discount/Interest: " + df.format(total_int));
  131.             System.out.printf("Total Amount: " + df.format(total_Amount));
  132.             System.out.printf("Monthly Amortization: " + df.format(monnthly_Amortization));
  133.             break;
  134.         case 4:
  135.             total_int = productPrice * (twelveMon_interest / 100);
  136.             total_Amount = productPrice + total_int;
  137.             monnthly_Amortization = total_Amount / 12;
  138.             System.out.println("Mode of Payment: 12 Months Installment");
  139.             System.out.println("Item: " + productName);
  140.             System.out.printf("Price: " + df.format(productPrice));
  141.             System.out.printf("Discount/Interest: " + df.format(total_int));
  142.             System.out.printf("Total Amount: " + df.format(total_Amount));
  143.             System.out.printf("Monthly Amortization: " + df.format(monnthly_Amortization));
  144.             break;
  145.         default:
  146.             System.out.println("Invalid input!");
  147.         }
  148.     }
  149. }
  150.  
Add Comment
Please, Sign In to add comment