Question

Write a method called CalculateShipping that computes and returns the shipping cost of an item for...

Write a method called CalculateShipping that computes and returns the shipping cost of an item for an online store.

The store's shipping policy states that shipping costs 75 cents per item, plus 25 cents for each ounce of product weight. There is an exception for items priced $100.00 or more, for which shipping is free.

So for an item that costs $12.99 and weighs 6 ounces, the shipping cost is computed as $0.75 + 6 * $0.25 = $2.25. For an item that costs $150.00, shipping costs $0.00.

Also write calls to the method that compute the shipping costs for the 2 above examples, placing the results in variables named cheapItem and expensiveItem.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Java code :

class Main{
  
static double calculateShipping(double cost, double weight){
if(cost>=150){
return 0;
}
return (75d+25d*weight)/100d;
}
public static void main(String[] args) {
double cheapItem = calculateShipping(12.99, 6);
double expensiveItem = calculateShipping(150, 10);
System.out.println("Shipping Cost of cheap item is $"+cheapItem);
System.out.println("Shipping Cost of expensive item is $"+expensiveItem);
}
}

OUTPUT :

Output Sample2 (run) X Shipping Cost of cheap item is $2.25 BUILD SUCCESSFUL (total time: 1 second)

Add a comment
Know the answer?
Add Answer to:
Write a method called CalculateShipping that computes and returns the shipping cost of an item for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Bryer Company has used the FIFO method of valuing its inventory for the prior 12 years....

    Bryer Company has used the FIFO method of valuing its inventory for the prior 12 years. The accountants at Bryer Company would like to switch to LIFO since the economy is suffering from severe inflation. For the switch to occur Bryer Company must have its auditor's approval and place a note in its financial statements, also, the auditor must refer to the change in its audit opinion. Bryer Company cannot make a change to its inventory valuation method once a...

  • Develop and write the complete Price Equation for an Apple iPad. Students identify the costs, discounts,...

    Develop and write the complete Price Equation for an Apple iPad. Students identify the costs, discounts, fees/charges, etc. for each item listed to complete the Price Equation for an Apple iPad Air. Here are some of the accessories and options available:    a.   List Prices—Apple Online Store: (NOTE: APPLE’S PRICES MAY CHANGE TO NEW PRICES WITHOUT NOTICE.)              –   Apple iPad Air Finish/Model: Black/Space Gray, 128GB, Wi-Fi + Cellular; MSRP is $929.00.              –   Network Carrier—Verizon: Assume you’re a heavy data user (video downloads, Internet...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT