Question

Your instructor would like you to write a program in Java which would ask for the clerk to enter ...

Your instructor would like you to write a program in Java which would ask for the clerk to enter the total amount of the customer’s order. The program will then calculate a seven percent (7%) sales tax. Commission is computed based on the following: order amount id="mce_marker" - $200 commission is 2%, order amount $201 - $400 commission is 3%, order amount $401 - $600 commission is 4%, order amount > $600 commission is 5%, The program will display the following: a) The amount of customer’s order (eg. $500.00 or id="mce_marker",000.00) b) The tax amount c) The total amount including tax added d) Commission Amount e) The customer will make five orders, display the average of the total order and the sum of all orders. You must use at least two methods. Write the output to a file named “Order.txt” The program should also display “Thanks for your business and please come again.” Output The amount of Customer’s order $XXX, XXX.XX The tax amount is: $XXX,XXX.XX The total Amount plus Tax is $XXX,XXX.XX Average order is $XXX,XXX,XX Sum of the order is $XXX,XXX.XX

Java only Thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

/*CustomerOrder class */
public class CustomerOrder {
   /* Definition of main method */
    public static void main(String args[]) throws IOException {
        double amt,salesTax,commission,totalOrderAmt=0;
        int i=0;
       String formatted;
        FileWriter fw=new FileWriter("Order.txt");       //attaching a file to filewriter
       //Loop will run 5 times to enter the customer order amount
        while(i < 5) {
            i++;
            System.out.print("\nEnter customer order: ");
            Scanner sc = new Scanner(System.in);
            amt = sc.nextDouble();
            totalOrderAmt += amt;
            salesTax = amt * 0.07;
            commission = calculateCommission(amt);
            System.out.printf("The amount of customer's order: $%.2f\n",amt);
            System.out.printf("The tax amount: $%.2f\n" ,salesTax);
            System.out.printf("The total amount including tax added: $%.2f\n",(amt + salesTax));
            System.out.printf("Commission amount: $%.2f\n",commission);
          
           formatted = String.format("The amount of customer's order: $%.2f\n",amt);
            fw.write(formatted);
           formatted = String.format("The tax amount: $%.2f\n" ,salesTax);
            fw.write(formatted);
           formatted = String.format("The total amount including tax added: $%.2f\n",(amt + salesTax));
            fw.write(formatted);
           formatted = String.format("Commission amount: $%.2f\n\n",commission);
            fw.write(formatted);
        }
        System.out.printf("\n\n\nThe sum of all orders: $%.2f\n",totalOrderAmt);
        System.out.printf("The average of the total order: $%.2f\n",totalOrderAmt/5);
       formatted = String.format("\n\n\nThe sum of all orders: $%.2f\n",totalOrderAmt);
       fw.write(formatted);
        formatted = String.format("The average of the total order: $%.2f\n",totalOrderAmt/5);
       fw.write(formatted);
      
        System.out.println("\nThanks for your business and please come again.");
        fw.write("\nThanks for your business and please come again.");
        fw.close();
    }

/* Function definition to calculate commission*/
    public static double calculateCommission(double amt) {
        if(amt <= 200)
            return amt * 0.02;
        else if(amt > 200 && amt <= 400)
            return amt * 0.03;
        else if(amt > 400 && amt <= 600)
            return amt * 0.04;
        else
            return amt * 0.05;
    }
}


SCREEN SHOTS:

Definiton uf main methud 7 publc static void main(String aDD throws IOExceptionf double am,saesTax,commion,otOndeAmt- String/Programs/Javas javac CustomerOrder.java : /Programs/Javas java CustonerOrder Enter customer order: 6352 The anount of customİ he anant of customers adar SE362 IXI 6 The amount of customers order. S3435 .00 7 The tx amourt $24045 B The total amount

Add a comment
Know the answer?
Add Answer to:
Your instructor would like you to write a program in Java which would ask for the clerk to enter ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java, write a program that will ask the user to enter the amount of a...

    In Java, write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase...

  • Write a program that calculates the amount a person would earn over a 30-day period of...

    Write a program that calculates the amount a person would earn over a 30-day period of time if his/her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should display a table showing the salary for each day, and then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies. A sample output might look...

  • This is JAVA. Must write a short description of this program, usually a sentence or two...

    This is JAVA. Must write a short description of this program, usually a sentence or two will be sufficient. All the classes, methods and data fields should be clearly documented (commented). Write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should display the amount of...

  • JAVA. Write a Java program that accepts the total amount of cars sold and total sales...

    JAVA. Write a Java program that accepts the total amount of cars sold and total sales amount of a car salesperson for a given month. The salesperson’s paycheck is computed as follows: a. Every sales person gets 10% (commission) of total sales b. Sales totals greater than $50,000 get 5% of total sales amount c. 8 or more cars sold earns the salesperson an extra 3% Please remove 30% (taxes) of the gross pay and list the paycheck amount. Your...

  • You are hired by a college to write a Java program to use a so-called check...

    You are hired by a college to write a Java program to use a so-called check sum technique for catching typing errors of student ID. The college assigns a seven-digit number to each student. The seventh digit (i.e., the rightmost digit) is determined from the other digits with the use of the following formula: 7th digit = (1 *(1st digit) * 2 * (2nd digit) * ... * 6 * (6th digit)) % 10 Your program should prompt users to...

  • Java I - Write a program that will use static methods as described in the specifications below. U...

    Java I - Write a program that will use static methods as described in the specifications below. Utilizing the if and else statements, write a program which will calculate a commission based on a two-tiered commission plan of 2% and 5% paid on amounts of $10,000 or less, or over $10,000 in monthly sales by a sales force paid on a commission basis. Use the output specifications below. --- (Please make detailed comments so I can better understand the code....

  • Write a program that asks the user to enter the types of dark chocolate and the...

    Write a program that asks the user to enter the types of dark chocolate and the number of packages purchased at the SHSU@ACM freshly made store. Make sure that you display the following chart for the user to make the selection. The plain base chocolate cost $5.00. The flavor and sweetness can be added to add on various rate. Chocolate Intensity Percentage                   Flavor & Sweetness              Cost Rate             1 - 25%                                               Super Sweet                            10% 26 - 50%        ...

  • Write a JAVA program to monitor the flow of an item into an out of a...

    Write a JAVA program to monitor the flow of an item into an out of a warehouse. The warehouse has numerous deliveries and shipments for this item (a widget) during the time period covered. A shipment out (an order) is billed at a profit of 50% over the cost of the widget. Unfortunately each incoming shipment may have a different cost associated with it. The accountants of the firm have instituted a last-in, first out system for filling orders. This...

  • What to submit: your answers to exercises 2. Write a Java program to perform the following...

    What to submit: your answers to exercises 2. Write a Java program to perform the following tasks: The program should ask the user for the name of an input file and the name of an output file. It should then open the input file as a text file (if the input file does not exist it should throw an exception) and read the contents line by line. It should also open the output file as a text file and write...

  • Java Programming Reading from a Text File Write a Java program that will use an object...

    Java Programming Reading from a Text File Write a Java program that will use an object of the Scanner class to read employee payroll data from a text file The Text file payroll.dat has the following: 100 Washington Marx Jung Darwin George 40 200 300 400 Kar Car Charles 50 22.532 15 30 The order of the data and its types stored in the file are as follows: Data EmployeelD Last name FirstName HoursWorked double HourlyRate Data Tvpe String String...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT