Enter in name ....need a little bit of help!
Hey guys i'm working on a following project that gives a person how much money there car is going to be with sales tax. here is my code
import java.util.Scanner;
import java.text.DecimalFormat;
public class tad
{
public static void main(String[] args)
{
final double INTEREST_RATE = 0.075;
DecimalFormat df = new DecimalFormat("#,000.00");
Scanner s = new Scanner(System.in); // create a Scanner object
String input; // read in user input as a string
double carPrice;
double carTax;
double carTotal;
double personName;
System.out.print("Please enter your first name ");
input = s.nextLine();
personName = Double.parseDouble(input);
System.out.print("Enter the price of the car: "); // user prompt
input = s.nextLine(); // read input as a string
carPrice = Double.parseDouble(input);
carTax =(carPrice*INTEREST_RATE);
carTotal=(carPrice + carTax);
System.out.println ("The Sales tax on your purchase is $" + df.format (carTax));
System.out.println ("making the total $" + df.format (carTotal));
}
} this is what the programs looks like running
Please enter your first name 99 (i put 99 because i get an error when i type in a name)
Enter the price of the car: 12345.67
The Sales tax on your purchase is $925.93
making the total $13,271.60
it needs to look like this....
Please enter your first name Adam
Enter the price of the car: 12345.67
Adam,
The Sales tax on your purchase is $925.93
making the total $13,271.60.
thanks alot for your help fellas!
Re: Enter in name ....need a little bit of help!
Just so you know, people will not directly give you an answer to your problem. They will (or should) instead, guide you to find the answer..
Anyway, what exactly is the problem you are having?