Monday
September 1, 2014

Homework Help: Computer Science Computer Programming

Posted by AB on Monday, May 21, 2012 at 9:01pm.

Please help! I cannot figure out what I am doing wrong. I cannot get the correct output when I run the system.

Here is what I have entered in to Netbeans IDE:

package shippingcharges;

public class ShippingCharges
{
private double weight;
private int miles;

public ShippingCharges (double w, int m)
{
weight = w;
miles = m;
}

public double getShippingCharges()
{

double charges;

if (weight <=2.0);
{
charges = 1.10 * (miles/500);
}
if ((weight >2.0) && (weight <= 6.0))
{
charges = 2.20 * (miles/ 500);
}
else if ((weight >6.0) && (weight <= 10.0))
{
charges = 3.70 * (miles/ 500);
}
else
{
charges = 3.80 * (miles/ 500);
}

return charges;

}
}


Next one is:

package shippingcharges;

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

public class charges
{
public static void main(String[] args)
{
double weight;
int miles;

Scanner keyboard = new Scanner(System.in);

DecimalFormat money = new DecimalFormat("0.00");

System.out.print("Enter the package weight: ");
weight = keyboard.nextDouble();
System.out.print("Enter the miles shipped: ");
miles = keyboard.nextInt();

ShippingCharges myPackage = new ShippingCharges (weight, miles);

System.out.println("Total charges will be $" +
money.format(myPackage.getShippingCharges()));
}
}

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

acct.information system components - can someone correct these for me when you ...
programming - How do you write a program that prints out your course schedule ...
Fund of programming 1 - Write a program that prints out your course schedule for...
Computer Science - Can anyone tell me where one could find help and advice for a...
English - Let's write down what you can do with the computer. 1. I use the ...
probability - out of 250 students interviewed at a community college, 90 were ...
Computer problem: related to finishing my homework - This is not a homework ...
computer programming - how do I figure out the math problem for Excel 2010?
algebra - Okay, I'm working with ultiplying Polynomials, and I just can't figure...
Computer programming? - What is jsp structures regrading to computer programming...

Search
Members