Answer to Question #264558 in Java | JSP | JSF for Zach

Question #264558

A local pizza shop is selling a large pizza for $9.99. Given the number of pizzas to order as input, output the subtotal for the pizzas, and then output the total after applying a sales tax of 6%.

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:

System.out.printf("Subtotal: %.2f\n", yourValue);

Ex: If the input is:

3

the output is:

Subtotal: $29.97
Total due: $31.77
1
Expert's answer
2021-11-12T00:07:58-0500
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    Scanner input=new Scanner(System.in);
	    System.out.println("Enter the number of pizzas to be ordered");
	    int n=input.nextInt();
	    double amount=9.99*n;
	    double total=0.06*amount+amount;
		System.out.println("SubTotal:%.2f "+amount);
		System.out.println("Total Due: %0.2f "+total);
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS