Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 22nd, 2007, 12:34 PM
sasuke85 sasuke85 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 1 sasuke85 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 33 sec
Reputation Power: 0
Need help on how to display the message for my practise in java

hi I kind of need some help you see I want to display the message that says on the javac in command prompt that says

//Enter parcel weight:
//200
//A 200 gram parcel costs $2.50 to deliver.

the problem is the formula that bothers me a lot

Weight Range Delivery Cost
Up to 200 grams 2.50
201 to 500 grams 4.00
501 to 100 grams 6.50
1001 to 5 kg 6.50 plus 50 cents for each additional 500 grams or part there of
Over 5 kg 14.00

Parcels over 15kg are not accepted

the formula that I can come up with is 1001-501/500*0.50 + 6. 50 is 7.00 but when it says over 5kg (5000 grams) for 5001 grams and up to 15 kg

the number is that not good since if I use 5001-501/500*0.50+6.50 is 11.00

that's where I want the number over 5kg up to 15kg is 14.00

here's the code that I have written.


/* File: DeliveryCompany.java
Author: Andrew
Date: September 18 2007
Purpose: To show that the Parcel deliver shows the actually values
*/

import java.util.Scanner;
import java.text.DecimalFormat;

public class DeliveryCompany
{

private static DecimalFormat currency = new DecimalFormat("$ #, ## 0.00");
public static void main(String[] args)
{

//Declartions
int weightParcel; = 0;
double deliveryCost; = 0;
double newWeightParcel; = 0;
Scanner input = new Scanner(System.in);


//prompt the user for entering the parcel weight
System.out.println("Please enter parcel weight");
weightParcel = input.nextInt();

//convert delivery cost into money sign

deliveryCost(Currency.format(deliveryCost);

// make decision on weight parcel

if(weightParcel < = 0)
{

if(weightParcel <= 201)
{
if(weightParcel <=501)
{
if(weightParcel <= 1001)
{
if(weightParcel <= 5001)
{

if (weightParcel <= 150001)
{

deliveryCost = 0;
}
else
{
deliveryCost = 14.00;
}
}
else
{
newWeightParcel = weightParcel-1001/500*0.50 +6.50;
}
}
else
{
deliveryCost = 6.50;
}

}
else
{
deliveryCost = 4.00;

deliveryCost = 2.50;


}
else
{
system.out.print("Sorry that number is invalid.")

}

}


}
// display results
System.out.print("A " + weightParcel + "will cost" + deliveryCost + "to deliver");

}

}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Need help on how to display the message for my practise in java


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway