Design a program named ClothDesigns This is a program to allow a customer to pla
ID: 3622394 • Letter: D
Question
Design a program named ClothDesignsThis is a program to allow a customer to place an order with a company named:
Cloth Designs Ltd. that makes a small number of cloth items with optional designs on them.
Your program will do the following:
present a greeting message:
Welcome to Cloth Designs Ltd.
we sell small cloth items with designs on them
(Credit for shipping of 5.00 applied
if cost of items is $50 or more.)
Then the menu and prompt:
Item:
1. Hand Warmers: $2.25
2. Oven Mits: $4.35
3. Baby Bib: $14.95
4. Pillow Case: $18.95
5. Cell Pocket: $2.35
Pick your number (hit enter)?
The user will enter the choice 1 to 5 and hit enter
Then the user will see the menu to pick a design:
Design:
1. Plain: $0.00
2. Flag: $1.25
3. Rainbow $2.50
Pick your number (hit enter)?
and then a menu to pick the shipping method:
Shipping:
1. UPS $5.00
2. overnight: $10.00
Pick your number (hit enter)?
Now ask the user how many items he wants with this prompt:
Quanity of items?
Calculate the total for the items by multiplying the quanity by the item price Subtract 5.00 from the shipping if this total is greater then or equal to $50.00, and give the user the following message if it is:
:) you are saving 5.00 on shipping :)
Add the final shipping price to the total for the items to get the grand total.
Print all the information out for a order confirmation. following is a example run of the program. Yours should exactly emulate it. Use the jar file from the testing link to see exactly how the programs behaves and 'reverse engineer' it so your program does exactly the same.
Welcome to Cloth Designs Ltd.
we sell small cloth items with designs on them
(Credit for shipping of 5.00 applied
if cost of items is $50 or more.)
Item:
1. Hand Warmers: $2.25
2. Oven Mits: $4.35
3. Baby Bib: $14.95
4. Pillow Case: $18.95
5. Cell Pocket: $2.35
Pick your number (hit enter)?
3
Design:
1. Plain: $0.00
2. Flag: $1.25
3. Rainbow $2.50
Pick your number (hit enter)?
2
Shipping:
1. UPS $5.00
2. overnight: $10.00
Pick your number (hit enter)?
2
Quanity of items?
5
:) you are saving 5.00 on shipping :)
YOUR ORDER:
Quanity 5 of item: Baby Bib with Flag design
Items Price: 81.00
Shipping: 5.00 (overnight)
You owe: 86.00
Explanation / Answer
Hope this helps. Let me know if you have any questions. Please rate. :) import java.util.Scanner; public class ClothDesigns { public static void main(String[] args) { int itemNum, designNum, shippingNum, quantity; double itemCost, designCost, shippingCost = 0, subtotal, totalCost; Scanner s = new Scanner(System.in); printGreeting(); System.out.println(); itemNum = getItem(s); itemCost = getItemCost(itemNum); System.out.println(); if (itemCost < 0) { System.out.println("Invalid item. Exiting program."); System.exit(-1); } designNum = getDesign(s); designCost = getDesignCost(designNum); System.out.println(); if (designCost < 0) { System.out.println("Invalid design. Exiting program."); System.exit(-1); } shippingNum = getShipping(s); if (shippingNum == 1) shippingCost = 5; else if (shippingNum == 2) shippingCost = 10; else { System.out.println("Invalid shipping. Exiting program."); System.exit(-1); } quantity = getQuantity(s); subtotal = quantity * (itemCost + designCost); if (subtotal >= 50.0) { System.out.println(":) you are saving 5.00 on shipping :)"); shippingCost -= 5.0; } totalCost = subtotal + shippingCost; System.out.println(); printOrder(itemNum, designNum, quantity, subtotal, shippingNum, shippingCost, totalCost); } public static void printGreeting() { System.out.println("Welcome to Cloth Designs Ltd."); System.out.println("we sell small cloth items with designs on them"); System.out.println("(Credit for shipping of 5.00 applied"); System.out.println("if cost of items is $50 or more.)"); } public static int getItem(Scanner s) { System.out.println("Item:"); System.out.println("1. Hand Warmers: $2.25"); System.out.println("2. Oven Mits: $4.35"); System.out.println("3. Baby Bib: $14.95"); System.out.println("4. Pillow Case: $18.95"); System.out.println("5. Cell Pocket: $2.35"); System.out.println("Pick your number (hit enter)?"); return s.nextInt(); } public static double getItemCost(int itemNum) { if (itemNum == 1) return 2.25; if (itemNum == 2) return 4.35; if (itemNum == 3) return 14.95; if (itemNum == 4) return 18.95; if (itemNum == 5) return 2.35; return -1.0; } public static int getDesign(Scanner s) { System.out.println("Design:"); System.out.println("1. Plain: $0.00"); System.out.println("2. Flag: $1.25"); System.out.println("3. Rainbow $2.50"); System.out.println("Pick your number (hit enter)?"); return s.nextInt(); } public static double getDesignCost(int designNum) { if (designNum == 1) return 0.0; if (designNum == 2) return 1.25; if (designNum == 3) return 2.5; return -1.0; } public static int getShipping(Scanner s) { System.out.println("Shipping:"); System.out.println("1. UPS $5.00"); System.out.println("2. overnight: $10.00"); System.out.println("Pick your number (hit enter)?"); return s.nextInt(); } public static int getQuantity(Scanner s) { System.out.println("Quanity of items?"); return s.nextInt(); } public static void printOrder(int itemNum, int designNum, int quantity, double subtotal, int shippingNum, double shippingCost, double totalCost) { System.out.println("YOUR ORDER:"); System.out.print("Quanity " + quantity + " of item: "); if (itemNum == 1) { System.out.print("Hand Warmers"); } else if (itemNum == 2) { System.out.print("Oven Mits"); } else if (itemNum == 3) { System.out.print("Baby Bib"); } else if (itemNum == 4) { System.out.print("Pillow Case"); } else if (itemNum == 5) { System.out.print("Cell Pocket"); } else { System.out.print("ERROR"); return; } System.out.print(" with "); if (designNum == 1) { System.out.print("Plain"); } else if (designNum == 2) { System.out.print("Flag"); } else if (designNum == 3) { System.out.print("Rainbow"); } else { System.out.print("ERROR"); return; } System.out.println(" design"); System.out.printf("Items Price: %.2f ", subtotal); System.out.printf("Shipping: %.2f", shippingCost); if (shippingNum == 1) { System.out.println("(UPS)"); } else if (shippingNum == 2) { System.out.println("(overnight)"); } else { System.out.println("ERROR"); return; } System.out.printf("You owe: %.2f ", totalCost); } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.