2. Write the appropriate Java statement to match the description in each of the
ID: 3560371 • Letter: 2
Question
2. Write the appropriate Java statement to match the description in each of the following comments:
// declare an integer variable for the cost of an item
// declare a double variable for the sales tax percentage
// prompt the user for the item cost
// input the item cost
// prompt the user for the sales tax percentage
// input the sales tax percentage
// output the amount of sales tax owed on the item,
// found by multiplying the item cost by the sales
// tax percentage
3. After each sequence of statements, indicate the purpose of the code in that sequence. Double balance;
double deposit;
double checks;
System.out.print(
Explanation / Answer
2. Write the appropriate Java statement to match the description in each of the following comments:
// declare an integer variable for the cost of an item
int cost;
// declare a double variable for the sales tax percentage
double sales_tax;
// prompt the user for the item cost
System.out.print("Enter item cost: ");
// input the item cost
cost = console.nextInt();
// prompt the user for the sales tax percentage
System.out.print("Enter sales tax percentage: ");
// input the sales tax percentage
sales_tax = console.nextDouble();
// output the amount of sales tax owed on the item,
// found by multiplying the item cost by the sales
// tax percentage
System.out.println("Amount of sales tax is " + sales_tax*cost);
3. After each sequence of statements, indicate the purpose of the code in that sequence. Double balance;
// declare an double variable for deposit
double deposit;
// declare an double variable for checks
double checks;
// prompt the user for balance
System.out.print(
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.