Code example 2-1 import java.util.Scanner; public class InvoiceApp { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String choice = “y”; While (choice.equals(“y”)) { System.out.print("Enter subtotal: "); double subtotal = sc.nextDouble(); double salesTax = subtotal * .0875; double invoiceTotal = subtotal + salesTax; String message = “Subtotal = ” + subtotal + “\n” + “ Sales tax = ” + salesTax + “\n” + “Invoice total = ” + invoiceTotal + “\n\n” System.out.println(message); System.out.print(“Continue? Enter y or n: ”); Choice = sc.next(); } } } (Refer to code example 2-1.) If the user enters 100 the first time the while loop is executed, what will the program display at the console? a. Subtotal: 100.0 Sales tax: 8.75 Invoice total: 108.75 b. Subtotal = 100.0 Sales tax = 8.75 Invoice total = 108.75 c. Subtotal = 100.0 Sales tax = 8.75Invoice total = 108.75 d. Subtotal = 100.0 Sales tax = 8.75Invoice total = 108.75
Code example 2-1
import java.util.Scanner;
public class InvoiceApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String choice = “y”;
While (choice.equals(“y”)) {
System.out.print("Enter subtotal: ");
double subtotal = sc.nextDouble();
double salesTax = subtotal * .0875;
double invoiceTotal = subtotal + salesTax;
String message = “Subtotal = ” + subtotal + “\n”
+ “ Sales tax = ” + salesTax + “\n”
+ “Invoice total = ” + invoiceTotal + “\n\n”
System.out.println(message);
System.out.print(“Continue? Enter y or n: ”);
Choice = sc.next();
}
}
}
(Refer to code example 2-1.) If the user enters 100 the first time the while loop is executed, what will the program display at the console? a. Subtotal: 100.0 Sales tax: 8.75 Invoice total: 108.75 b. Subtotal = 100.0 Sales tax = 8.75 Invoice total = 108.75 c. Subtotal = 100.0 Sales tax = 8.75Invoice total = 108.75 d. Subtotal = 100.0 Sales tax = 8.75Invoice total = 108.75
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images