Dear all,
What am I doing wrong here. If I input, say, 1025 then I get 49 as my netCost. Why is the program changing my figure. This is driving me up the wall. I have the feeling, I'm making a very simple error, I just have no idea what it is
Thank you in advance and Merry Festive Season,
Clinton
// ***************** Code ****************
import java.io.IOException;
public class NewYorkPlusTax {
public static void main(String[] args) {
double netCost;
double grossCost;
double taxAmount;
double TAX = 8.25; // this is a percentage
System.out.print("Enter Cost-Before-Tax of Item: "
try {
netCost = (double)System.in.read();
// netCost = Double.valueOf(System.in.read()).doubleValue();
System.out.println("Item price = " + netCost);
taxAmount = netCost * TAX / 100;
System.out.println("Tax on Item = " + taxAmount);
grossCost = netCost + taxAmount;
System.out.println("Total Amount = " + grossCost);
} catch (IOException ioe) {
System.out.println("User Error"
}
}
}
"The important thing is not to stop questioning." - Albert Einstein
What am I doing wrong here. If I input, say, 1025 then I get 49 as my netCost. Why is the program changing my figure. This is driving me up the wall. I have the feeling, I'm making a very simple error, I just have no idea what it is
Thank you in advance and Merry Festive Season,
Clinton
// ***************** Code ****************
import java.io.IOException;
public class NewYorkPlusTax {
public static void main(String[] args) {
double netCost;
double grossCost;
double taxAmount;
double TAX = 8.25; // this is a percentage
System.out.print("Enter Cost-Before-Tax of Item: "
try {
netCost = (double)System.in.read();
// netCost = Double.valueOf(System.in.read()).doubleValue();
System.out.println("Item price = " + netCost);
taxAmount = netCost * TAX / 100;
System.out.println("Tax on Item = " + taxAmount);
grossCost = netCost + taxAmount;
System.out.println("Total Amount = " + grossCost);
} catch (IOException ioe) {
System.out.println("User Error"
}
}
}
"The important thing is not to stop questioning." - Albert Einstein