Steps: 1. Create a new Java project in Eclipse named CalculateTotal 2. Create a
ID: 3742035 • Letter: S
Question
Steps:
1. Create a new Java project in Eclipse named CalculateTotal
2. Create a new Java source file named CalculateTotal.java
3. Paste the code below into your newly created file
4. Fix the bugs
5. Submit your corrected Java file.
Code:
import java.text.DecimalFormat;
/This program calculates a total based on merchandise total, shipping amount, and tax.
//It then outputs the total to the console.
public class CalculateTotal {
public static void main(string args) {
int ItemTotal = 500.50;
double Shipping = 10;
double TaxRate = .05
double SubTotal = ItemTotal + Shipping;
double Total = SubTotal + (SubTotal / Tax);
DecimalFormat df = new DecimalFormat("####.##"));
//Total should be 536.02
System.out.println("Your total is: $' + df.format(Total));
};
}
I need to know where the bugs are or any mistakes. I have some narrowed down but I hope I can get help.
Explanation / Answer
import java.text.DecimalFormat;
public class CalculateTotal {
public static void main(String[] args) {
double ItemTotal = 500.50;
double Shipping = 10;
double TaxRate = .05;
double SubTotal = ItemTotal + Shipping;
double Total = SubTotal *(1+TaxRate);
DecimalFormat df = new DecimalFormat("####.##");
System.out.println("Your total is: $" + df.format(Total));
}
}
// Output: Your total is: $536.02
// Hit the thumbs up if you are happy with the answer.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.