Question

In: Computer Science

7) Create the following using Java. Create a scanner Declare double variables for price and tax...

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)

Solutions

Expert Solution

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');
  
    }
}



Related Solutions

8) Create the following program using Java. Circle calculation using methods Create scanner declare double variable...
8) Create the following program using Java. Circle calculation using methods Create scanner declare double variable radius = -999 declare character choice create do while loop inside of do loop write: System.out.println(); System.out.println("*** CIRCLE CALCULATIONS ***"); System.out.println(); System.out.println("1. Enter the radius of the circle"); System.out.println("2. Display the area of the circle"); System.out.println("3. Display the circumference of the circle"); System.out.println("4. Quit"); System.out.println(); System.out.println("Enter a number from 1 - 4"); System.out.println(); Declare choice character and relate to scanner declare switch (choice) case...
5) Create the following in a Java program Create a scanner Prompt the user to enter...
5) Create the following in a Java program Create a scanner Prompt the user to enter the name where the box of mail is shipping from and create the variable and relate to scanner Prompt the user to enter the name of destination where the box of mail will be shipped and create the variable and relate to scanner Prompt the user to enter the weight of the package and create variable to relate to scanner Calculate cost of shipping...
in java my code double price[] = {26.99, 22.99, 13.99, 56.99, 38.99}; // Variable Declaration Scanner...
in java my code double price[] = {26.99, 22.99, 13.99, 56.99, 38.99}; // Variable Declaration Scanner keyIn = new Scanner(System.in); //Header System.out.println( "----------------------------------------\n" + " Grocery Shop Price Calculator \n" + "----------------------------------------\n") ; System.out.print ("Please enter the quantities for each item in the list? "); double totalCost = 0; double fishAmount = 0; for(int i=0; i<price.length; i++) { int items = Integer.parseInt(keyIn.nextLine()); if(i==4) fishAmount = price[i]*items; else totalCost = totalCost + price [i]*items; } System.out.print("Do you have the membership(Y/N) ");...
This for Java Programming Write a java statement to import the java utilities. Create a Scanner...
This for Java Programming Write a java statement to import the java utilities. Create a Scanner object to read input. int Age;     Write a java statement to read the Age input value 4 . Redo 1 to 3 using JOptionPane
Java language (a) Write code segments to perform the following: (i) declare and create an integer...
Java language (a) Write code segments to perform the following: (i) declare and create an integer array freqArray of size 8 (ii) declare and initialize an array weight (with suitable type) which contains 48.5, 80 and 68 (iii) declare a Mouse array of size 2 with name mouse and initialize it with Mouse objects using one statement (b) A incomplete definition of a class Temperature is given below: public class Temperature { private double value[] = {36.5, 40, 37, 38.3};...
Create an object called Circle. Declare the following integer variables for the object Circle, radius, diameter,...
Create an object called Circle. Declare the following integer variables for the object Circle, radius, diameter, and pi is declared as double. Create the following for the Circle object: ● Implicit constructor (default constructor) ● Void method Calculate (double pi, int radius) to calculate the area of the Circle object. The method must include a system.out statement that displays the area value. Use the following formula to calculate area of the circle: Area = pi * (r * r) Your...
Given the following Java source code fragment double price[]; price = new double[16]; What's the name...
Given the following Java source code fragment double price[]; price = new double[16]; What's the name of the array? How many elements are in the array? What's the index of the first element in the array? What's the index of the last element in the array? What's the value of the element at index 3 after the last statement executes?
using java Create a class Rectangle with attributes length and width both are of type double....
using java Create a class Rectangle with attributes length and width both are of type double. In your class you should provide the following: Provide a constructor that defaults length and width to 1. Provide member functions that calculate the area, perimeter and diagonal of the rectangle. Provide set and get functions for the length and width attributes. The set functions should verify that the length and width are larger than 0.0 and less that 50.0. Provide a member function...
3) Create a Java program that uses NO methods, but use scanner: Write a program where...
3) Create a Java program that uses NO methods, but use scanner: Write a program where you will enter the flying distance from one continent to another, you will take the plane in one country, then you will enter miles per gallon and price of gallon and in the end it will calculate how much gas was spend for that distance in miles. Steps: 1) Prompt user to enter the name of country that you are 2) Declare variable to...
Exercise 2: Write a program in Java to manipulate a Double Linked List: 1. Create Double...
Exercise 2: Write a program in Java to manipulate a Double Linked List: 1. Create Double Linked List 2. Display the list 3. Count the number of nodes 4. Insert a new node at the beginning of a Double Linked List. 5. Insert a new node at the end of a DoubleLinked List 6. Insert a new node after the value 5 of Double Linked List 7. Delete the node with value 6. 8. Search an existing element in a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT