Rainbow Paint Store Method Project

advertisement
Lab Project for Methods
You are employed by the
Rainbow Paint Store.
For the purposes of this program, the Rainbow Paint Store
RED and GREEN gallons of paint.
Your task:
1. From main, ask the customer which paint color they wish to purchase and how many
full gallons of paint are needed. Design the program to allow the customer to make
additional purchases of either color of paint.
2. Establish a method to deal with each color of paint (2 methods).
The method for the red paint: determine the cost of the paint based upon $21.95 per
gallon. Return the total cost to main.
The method for the green paint: determine the cost of the paint based upon $19.95
per gallon. Return the total cost to main.
3. Establish a method to print the store title for billing purposes.
4. Establish a method that determines a total bill for the customer. This method will
receive the totals from the two paint methods, will compute the final total cost, and
will add 8% sales tax to the order. Return this final total to main.
5. Establish a method to print a thank-you message for buying at this store.
6. Print a bill for the customer. The bill is to be developed in the following order:
the store name, the total cost of each paint color, the total bill with sales tax, and the
thank you message.
7. Be sure that the money amounts are printed as money amounts.
only sells
import cs1.Keyboard;
public class RainbowPaint
{
public void newPurchase()
{
String color;
int gallons = 0, redGallons = 0, greenGallons = 0;
double redTotal = 0, greenTotal = 0;
double redCost = 21.95;
double greenCost = 19.95;
char answer;
//Dealing with store transactions
do
{
// ask what color paint they would like to purchase and read response
// ask how many gallons of that paint color they would like and read response
if(color.equalsIgnoreCase("red"))
{
// add to red gallons
}
else if(color.equalsIgnoreCase("green"))
{
// add to green gallons
}
else
{
System.out.println("Sorry! We don't have that color in stock!");
}
// ask if they want to buy more paint
}
// while (yes they want more paint)
//call red method and pass # of red gallons and cost of red paint. Return value to redTotal
//call green method and pass # of green gallons and cost of green paint. Return value to greenTotal
//Print the bill
}
//Method for the cost of red paint here
//Method for the cost of green paint here
//Method for the Store Name Logo here
//Method to find the total bill here
//Method to print a thank you message here
Output should look similar to:
What color paint would you like to purchase? red
How many gallons of red would you like to purchase? 4
Would you like to purchase more paint?(y/n) y
What color paint would you like to purchase? green
How many gallons of green would you like to purchase? 7
Would you like to purchase more paint?(y/n) y
What color paint would you like to purchase? red
How many gallons of red would you like to purchase? 2
Would you like to purchase more paint?(y/n) y
What color paint would you like to purchase? tan
How many gallons of tan would you like to purchase? 8
Sorry! We don't have that color in stock!
Would you like to purchase more paint?(y/n) n
***************************
* The Rainbow Paint Store *
***************************
Total cost for Red Paint (6 gallons @ $21.95 each):
Total cost for Green Paint (7 gallons @ $19.95 each):
Your total paint cost plus 8% tax is:
Thank you for choosing The Rainbow Paint Store.
Please come again!
$131.70
$139.65
$293.06
Download