Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class InvoiceApp
- {
- public static void main(String[] args)
- {
- //Declare variables and Scanner object
- Scanner input = new Scanner(System.in);
- double discountpercent; //stores discount percent
- double discountamount; //stores discount amount
- double amount; //stores amount interger
- double total; //stores total amount
- double subtotal = 0; //stores subtotal amount
- int number; //number
- //Display a welcome message
- System.out.println("*****************************************************");
- System.out.println("\tWelcome to the Invoice Total Calculator");
- System.out.println("*****************************************************");
- //Prompt user for customer type
- System.out.print("Enter customer type (as an interger): ");
- //Read customer type
- number = input.nextInt();
- switch(number){
- case 1:
- if(subtotal >=500) {
- discountpercent = 0.20;
- }
- else if(subtotal < 500 && subtotal >= 250) {
- discountpercent = 0.15;
- }
- else if(subtotal < 250 && subtotal >= 100){
- discountpercent = 0.10;
- }
- else
- discountpercent = 0.00;
- break;
- case 2: discountpercent = 0.20; break;
- case 3:
- if(subtotal >=500) {
- discountpercent = 0.50;
- }
- else
- discountpercent = 0.40; break;
- default:
- discountpercent = 0.05;
- }//end of switch
- //Prompt user for subtotal
- System.out.print("Enter Subtotal: ");
- //Read subtotal
- subtotal = input.nextInt();
- //Calculate Discount Rate
- discountamount = (subtotal * discountpercent);
- //Calculate Invoice Total
- total = (subtotal - discountamount);
- //Display thank you message
- System.out.println("*****************************************************");
- System.out.println("\t\tINVOICE REPORT");
- System.out.println("\tSubtotal: \t\t" + subtotal);
- System.out.println("\tCustomer type: \t\t" + number);
- System.out.println("\tDiscount percent: \t" + discountpercent);
- System.out.println("\tDiscount amount: \t" + discountamount);
- System.out.println("\tTotal: \t\t" + total);
- System.out.println("\t\t Thank you!!");
- System.out.println("*****************************************************");
- //Format and display the results
- }//end of main
- }//end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement