Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.text.DecimalFormat;
- public class Main //Bianca
- {
- public static void main(String args[]) {
- Scanner sc = new Scanner(System.in);
- DecimalFormat df = new DecimalFormat("###,###.00");
- //Variable declaration
- String product1, product2, product3, productName = "";
- double price1, price2, price3, total_int, total_Amount,
- monnthly_Amortization;
- double cash_dis, threeMon_interest, sixMon_interest, twelveMon_interest,
- productPrice = 0;
- System.out.println("Sales Input:\n");
- System.out.print("Enter Product 1: ");
- product1 = sc.nextLine();
- System.out.print("Enter Price: $");
- price1 = sc.nextDouble();
- sc.nextLine();
- System.out.print("\nEnter Product 2: ");
- product2 = sc.nextLine();
- System.out.print("Enter Price: $");
- price2 = sc.nextDouble();
- sc.nextLine();
- System.out.print("\nEnter Product 3: ");
- product3 = sc.nextLine();
- System.out.print("Enter Price: $");
- price3 = sc.nextDouble();
- System.out.println("Input Mode of Payment Terms:\n");
- System.out.print("Cash Discount: ");
- cash_dis = sc.nextInt();
- System.out.println("You input " + (int) cash_dis +
- "% Discount for Cash\n");
- System.out.print("3 Months Installment: ");
- threeMon_interest = sc.nextInt();
- System.out.println("You input " + (int) threeMon_interest +
- "% Interest for 3 Months Installment\n");
- System.out.print("6 Months Installment: ");
- sixMon_interest = sc.nextInt();
- System.out.println("You input " + (int) sixMon_interest +
- "% Interest for 6 Months Installment\n");
- System.out.print("12 Months Installment: ");
- twelveMon_interest = sc.nextInt();
- System.out.println("You input " + (int) twelveMon_interest +
- "% Interest for 12 Months Installment\n");
- System.out.println("Main Menu\n\n");
- char p1 = product1.charAt(0);
- char p2 = product2.charAt(0);
- char p3 = product3.charAt(0);
- char c1 = Character.toLowerCase(p1);
- char c2 = Character.toLowerCase(p2);
- char c3 = Character.toLowerCase(p3);
- System.out.print("\nPress "+p1+"/"+c1+"\t\t"+product1+" "+df.format(price1));
- System.out.print("\nPress "+p2+"/"+c2+"\t"+product2+" "+df.format(price2));
- System.out.print("\nPress "+p3+"/"+c3+"\t"+product3+" "+df.format(price3));
- System.out.print("\nEnter Item: ");
- char item = sc.next().charAt(0);
- item = Character.toLowerCase(item);
- //first switch
- switch (item) {
- case 'i':
- System.out.println("Your Item is " + product1 + "\nPrice:\t\t$" +
- df.format(price1));
- productName = product1;
- productPrice = price1;
- break;
- case 's':
- System.out.println("Your Item is " + product2 +
- "\nPrice:\t\t$" + df.format(price2));
- productName = product2;
- productPrice = price2;
- break;
- case 'x':
- System.out.println("Your Item is " + product3 +
- "\nPrice:\t\t$" + df.format(price3));
- productName = product3;
- productPrice = price3;
- break;
- default:
- System.out.println("Invalid input!");
- }
- System.out.println("\nSelect Mode of Payment\n");
- System.out.println("Press 1: Cash " + (int) cash_dis +
- "% Discount");
- System.out.println("Press 2: 3 Months Installment " +
- (int) threeMon_interest + "% Interest");
- System.out.println("Press 3: 6 Months Installment " +
- (int) sixMon_interest + "% Interest");
- System.out.println("Press 4: 12 Months Installment " +
- (int) twelveMon_interest + "% Interest");
- System.out.print("\nEnter Mode of Payment: ");
- int pmode = sc.nextInt();
- //2nd switch
- switch (pmode) {
- case 1:
- total_int = productPrice * (cash_dis / 100);
- total_Amount = productPrice - total_int;
- System.out.println("Mode of Payment: Cash");
- System.out.println("Item: " + productName);
- System.out.printf("Price: " + df.format(productPrice));
- System.out.printf("Discount/Interest: " + df.format(total_int));
- System.out.printf("Total Amount: " + df.format(total_Amount));
- break;
- case 2:
- total_int = productPrice * (threeMon_interest / 100);
- total_Amount = productPrice + total_int;
- monnthly_Amortization = total_Amount / 3;
- System.out.println("Mode of Payment: 3 Months Installment");
- System.out.println("Item: " + productName);
- System.out.printf("Price: " + df.format(productPrice));
- System.out.printf("Discount/Interest: " + df.format(total_int));
- System.out.printf("Total Amount: " + df.format(total_Amount));
- System.out.printf("Monthly Amortization: " + df.format(monnthly_Amortization));
- break;
- case 3:
- total_int = productPrice * (sixMon_interest / 100);
- total_Amount = productPrice + total_int;
- monnthly_Amortization = total_Amount / 6;
- System.out.println("Mode of Payment: 6 Months Installment");
- System.out.println("Item: " + productName);
- System.out.printf("Price: " + df.format(productPrice));
- System.out.printf("Discount/Interest: " + df.format(total_int));
- System.out.printf("Total Amount: " + df.format(total_Amount));
- System.out.printf("Monthly Amortization: " + df.format(monnthly_Amortization));
- break;
- case 4:
- total_int = productPrice * (twelveMon_interest / 100);
- total_Amount = productPrice + total_int;
- monnthly_Amortization = total_Amount / 12;
- System.out.println("Mode of Payment: 12 Months Installment");
- System.out.println("Item: " + productName);
- System.out.printf("Price: " + df.format(productPrice));
- System.out.printf("Discount/Interest: " + df.format(total_int));
- System.out.printf("Total Amount: " + df.format(total_Amount));
- System.out.printf("Monthly Amortization: " + df.format(monnthly_Amortization));
- break;
- default:
- System.out.println("Invalid input!");
- }
- }
- }
Add Comment
Please, Sign In to add comment