Complete the OrderApp program below that uses the getCost() method to calculate the cost for some number
Question:
- Complete the OrderApp program below that uses the getCost() method to calculate the cost for some number of t-shirts, hoodies, or shorts. There is a $6.00 surcharge for each size x-large item.
- Here is the expected output for the program:
$ java OrderApp
5 t-shirts, size medium: $50.00
2 hoodies, size x-large: $72.00
3 shorts, size small: $45.00
- Here is the program that you must complete using the provided enumerations and class constants:
import java.util.*;
public class OrderApp {
public enum Size {SMALL, MEDIUM, LARGE, XLARGE}
public enum Item {TSHIRT, HOODIE, SHORTS}
public static final int TSHIRT_COST = 10;
public static final int HOODIE_COST = 30;
public static final int SHORTS_COST = 15;
public static final int XLARGE_SURCHARGE = 6;
public static void main(String[] args) {
System.out.println(" 5 t-shirts, size medium: $" + getCost(/* Add Code Here */) + ".00"); System.out.println(" 2 hoodies, size x-large: $" + getCost(/* Add Code Here */) + ".00"); System.out.println(" 3 shorts, size small: $" + getCost(/* Add Code Here */) + ".00"); } public static int getCost(Item i, Size s, int number) {
//Add code here } }
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill