Question
Please use Import. javax.swing.JOptiomPane for input and output. Thank you. Objective To build a complete working Java program that applies control structures and file processing.
Please use Import. javax.swing.JOptiomPane for input and output. Thank you.
Objective
To build a complete working Java program that applies control structures and file processing.
Overview & Instructions
Write a program that generates a sales summary report for a local coffee distribution company.
The DeltaJava Coffee Company runs a coffee bean distribution business. It sells only one type of coffee beans, harvested exclusively in the exotic region known as The Thumb of Michigan. The company sells the coffee in 2-lb bags only, and the price of a single 2-lb bag is $9.50. It sells both to local coffee businesses as well as non-profit (tax-exempt) organizations.
Shipping involves distribution of the coffee bags into boxes. The boxes come in three sizes:
a large box holds 20 bags and costs $4.80 to ship
a medium holds 10 bags and costs $3.20 to ship
a small box holds 5 bags and costs $1.60 to ship
The order is shipped in the least expensive manner. The rule for packing is to fill the large and medium boxes completely; that is, the box is fully packed. Only the small boxes can have empty spaces. For example, the order of 52 bags will be shipped in four boxes: two large, one medium, and one small.
DeltaJava gives discounts to volume buyers. The discount is based on the following table:
Order | Volume Discount |
25 bags | 5% of base price |
50 bags | 10% of base price |
100 bags | 15% of base price |
150 bags | 20% of base price |
200 bags | 25% of base price |
300 bags | 30% of base price |
Michigan sales tax (6%) is charged for all companies unless they are designated as tax-exempt. Tax will be charged on the base cost of the order (i.e. before the discount and shipping adjustments are applied).
Rush ordering is available for customers. For one-day rush orders, add $40.00 to the total shipping cost and for two-day rush orders, add $25.00.
The file you need process will be: coffeeOrders.txt
Your program will read sales data line-by-line and generate a sales cost summary for each line. Sample data could be:
TomHortum r b 840 2 2-day rush order for 840 bags to a taxable business
IslandLakeLatte s b 300 Regular order for 300 bags to a taxable business
DeltaCollege r n 45 1 1-day rush order for 45 bags to a tax-exempt organization
Note that the first code after the name will always be either an r or an s. The second code will always be a b or an n. If the order is a rush order (r),then an additional field will be added to the end of the line indicating one- or two-day rush ordering. Assume an unknown number of orders in the file. Allow the end-of-file indicator to terminate the program.
Your output should appear as an organized, formal financial report summarizing each order in detail. Write your entire output report to an external file. An example format could be:
Boxes
Customer Base Cost Discount Tax Shipping Total Sm Md Lg
xxxxxxxxx $xxx.xx $xxx.xx $xxx.xx $xxx.xx $xxx.xx xx xx xx
xxxxxxxxx $xxx.xx $xxx.xx $xxx.xx $xxx.xx $xxx.xx xx xx xx
and so on ...
TOTALS $xxxx.xx $xxxx.xx xxx xxx xxx
After completing all output lines for each of the orders in the input file, write totals at the bottom of your report for the tax, total, and box columns. This implies accumulating the totals as you process them within the file loop and then writing them after the loop completes.
Java notes and hints:
To compare strings in Java use equals()
To extract a character from a String, use: aString.charAt(0)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started