Adding zip code specifications

Page 1 of 1

1 Replies - 111 Views - Last Post: 23 September 2012 - 03:20 PM Rate Topic: -----

#1 DCole  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-September 12

Adding zip code specifications

Posted 23 September 2012 - 03:19 PM

import java.util.Scanner; // Required for the Scanner class.

public class ShippingCharges2

{

public static void main (String[] args)

{
int zipcode; //Enter zipcode
int weight; //Enter weight of package
int length; //Enter length of package
int width; //Enter width of package
int height; //Enter height of package


Scanner input = new Scanner(System.in); // Create a Scanner object for the input.

//Get the zipcode of the package
System.out.println(" What is the zipcode for th package? ");
zipcode = input.nextInt();

//Get the weight of the package
System.out.println("What is the weight of the package (in pounds)? ");
weight = input.nextInt();

//Get the length of the package
System.out.println("What is the length of the package (in inches)? ");
length = input.nextInt();

//Get the width of the package
System.out.println("What is the width of the package (in inches)? ");
width = input.nextInt();

//Get the height of the package
System.out.println("What is the height of the package (in inches)? ");
height = input.nextInt();

if("Shipping charges=0 ");
{
if(weight <= 5)
System.out.println("Shipping cost is: $12.00 ")
}
else if(weight > 5 && weight <= 15)
{
System.out.println("Total Shipping Cost is: $14.00 ")
}
else if(weight > 15 && weight <= 34)
{
System.out.println("Total Shipping cost is: $17.00 ")
}
else if(weight > 34 && weight <= 45)
{
System.out.println("Total Shipping cost is: 21.00 ")
}
else if(weight > 34 && weight <= 45)
{
System.out.println("Total Shipping cost is: 33.00 ")
}
else
{
System.out.println("Total Shipping cost is 105.00 ")


This is what I have so far but I do not know how to add:

The additional charges are calculated as follows:
If the first digit of the zip code is a "4" then there is an additional surcharge of 5% on
the shipping cost.
If the first digit of the zip code is a "6" then there is an additional surcharge of 9% on
the shipping cost.
For all other zip codes there is an additional surcharge of 14% on the shipping cost.


Finally, if the zip code is even, then there is an additional surcharge of 2% of the
shipping cost.

Is This A Good Question/Topic? 0
  • +

Replies To: Adding zip code specifications

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8018
  • View blog
  • Posts: 31,126
  • Joined: 06-March 08

Re: Adding zip code specifications

Posted 23 September 2012 - 03:20 PM

Duplicated post
Please avoid double posting
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1