In: Computer Science
7) Create the following using Java.
Create a scanner
Declare double variables for price and tax
Declare character variable reply
Create do while loop
Inside of do loop
Prompt the console to display headline Product Price Check
Prompt the user to enter initial price and relate to scanner
Prompt the user to enter the tax rate and relate to scanner
Calculate price which is equal to price multiply (1+tax/100)
Display in console the cost after tax which is price
Check if user want to enter another product by (y/n)?
Declare replay equal to scanner .next.charAt(0)
import java.util.Scanner; //Import the Scanner class
import java.util.*;
public class Product {
public static void main (String[] args ) {
Scanner sc = new Scanner
(System.in); //Create a Scanner object
int cost;
char reply;
do{
System.out.println("Product Price Check");
System.out.print(" Enter Initial Product Price =
");
double myPrice = sc.nextInt(); //Read user input
System.out.print(" Enter Tax rate of Product = " );
double myTax = sc.nextInt(); //Read user input
cost = myPrice*(1+(myTax/100));
System.out.println("cost after tax of the product = "
+cost); //output user input
System.out.print("you want to enter another product?
(y/n)");
reply= sc.next().charAt(0);
}
while( reply=='y' || reply=='Y');
}
}