Answer to Question #246060 in Java | JSP | JSF for Sezen

Question #246060

You will create Cart class as a context class to get total price and add product.

◦ To implement Strategy pattern, depending on the country of shipping, the relevant customs duty is charged and the shipping cost of Europe Shopping, America Shopping increases. Large products (XL-size) have an additional charge. Create AmericaShopping and EuropeShopping concrete class.

◦In the USA, the duty tax is 1% and the base delivery fee is $15. In America, an additional tax different from the customs tax is applied and this tax is 0.75%. Customs duty should be added to the item fee for each item.

◦In Europe, the customs duty is 1.5% and the base delivery fee is £11.

◦In America, $5 should be added to the shipping fee when each item is added. But if the added product size is XL, $10 should be added to the shipping fee. In Europe, this should only be done if the product size is XL.


1
Expert's answer
2021-10-03T17:14:56-0400


public class Main
{
	public static void main(String[] args) {
		AmericaShopping a=new AmericaShopping();
		a.print();
		EuropeShopping e=new EuropeShopping();
		e.print();
	}
}


class Cart{
    
}


class  AmericaShopping{
    double duty_tax=0.01;
    double base_delivery_fee=15;
    double add_tax=0.0075;
    double add_shipping_fee_sm=5;
    double add_shipping_fee_xl=10;
    
    public void print(){
        double total=0.01+15+0.0075+5+10;
        System.out.println("Total tax = "+total);
    }
    
}


class  EuropeShopping{
    double duty_tax=0.015;
    double base_delivery_fee=11;
    double add_shipping_fee_xl=10;
    public void print(){
        double total=0.015+11+10;
        System.out.println("Total tax = "+total);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS