programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Shipping Charge Calculator

Rithanya Laxmi
Ranch Hand
Posts: 203
Hi,

I want to write a Utility to calculate the shipping charges based on the product weight in pounds and distance in miles. Please let me know how we can go about it.

Thanks

Mohamed Sanaulla
Bartender
Posts: 3185
34
What is your business logic/requirement to decide the shipping charges? There should be some formula or some kind of case statements saying if productWeight > X and distance > Y then shippingCharge = Z.

Rithanya Laxmi
Ranch Hand
Posts: 203

The assignment has the following rates:

Weight of Package Rate per 500 miles shipped
-------------------- --------------------------------
2 pounds or less \$1.10
over 2 pounds but not more than 6 pounds \$2.20
over 6 pounds but not more than 10 pounds \$3.70
over 10 pounds \$3.80

The shipping charge per 500 miles are not prorated. For example, if a 2 pound package is shipped 502 miles, the charge would be \$2.20. Please let me know your thoughts.

Thanks.

Paweł Baczyński
Bartender
Posts: 2087
44
What have you tried so far? What do you have a problem with?

Shubham Semwal
Ranch Hand
Posts: 176
3
Rithanya Laxmi wrote:

Weight of Package Rate per 500 miles shipped
-------------------- --------------------------------
2 pounds or less \$1.10
over 2 pounds but not more than 6 pounds \$2.20
over 6 pounds but not more than 10 pounds \$3.70
over 10 pounds \$3.80

The shipping charge per 500 miles are not prorated. For example, if a 2 pound package is shipped 502 miles, the charge would be \$2.20. Please let me know your thoughts.

umm it appears to be having some conditions as rules. How do we use conditions in java ?? Find that and you're good to start

Paweł Baczyński
Bartender
Posts: 2087
44
Shubham Semwal wrote:umm it appears to be having some conditions as rules. How do we use conditions in java ?? Find that and you're good to start

Nope, that's not a good approach. OP needs first to figure out what algorithm to use. Only when he figures it out, he should wonder how to write it in Java.