File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes HELP ME PLEASE!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "HELP ME PLEASE!!!" Watch "HELP ME PLEASE!!!" New topic


Jessica Curtner

Joined: Mar 22, 2009
Posts: 2
I'm doing a project for school about shipping rates i need to make a program that will ask the user to enter a weight of a package and the amount of miles they want to ship it.. the rates per 500 miles are as follows:
2lbs or less 1.10
over 2 lbs but not more than 6lbs 2.20
6lbs but not more than 10 lbs 3.70
over 10 lbs is 3.80

I am having a hard time trying to figure out what i need to put in my code to have any package being sent under 500 miles get set to the minimum shipping rate listed above or is there a different way i should be setting this up??.. can someone please explain to me what i need to do i would greatly appreciate it.. Here is what i have so far:
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42954
It seems you're using the "distance" value incorrectly. A check for "distance < 500" doesn't make sense if earlier you defined "distance = miles / 500".

But since -in the format statement- you're multiplying by the distance value anyway, you should ask yourself: How do you need to take the distance value into account in those "if" statements?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14600

Welcome to JavaRanch. Please use a meaningful subject line instead something like "HELP ME PLEASE" when you post a topic.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Brian Pianczk
Ranch Hand

Joined: Jan 26, 2009
Posts: 45
Make sure you let everyone know about the cross threads.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42954
Indeed, please BeForthrightWhenCrossPostingToOtherSites. It's the polite thing to do.
rocket mass heater kickstarter
subject: HELP ME PLEASE!!!