Write a java program called Sales considering the following directions and the sample run. Practice here first the write answer on the answer sheet. Also, make sure to distinguish high and low caps as Java is case - sensitive.- import and declare a Scanner class- declare three floating – point variables named price, discount, and discountPrice- ask the user for the price (print statement) and get the price (Scanner) from the user- calculate the discount if price is less than 100, then the discount is 10% of price, else discount is 14% of price- print the discounted prices for the item Sample RunEnter the price90.0The discount price is 81.0 Enter the price200.0The discount price is 172.0

Question
Asked Mar 7, 2019

Write a java program called Sales considering the following directions and the sample run. Practice here first the write answer on the answer sheet. Also, make sure to distinguish high and low caps as Java is case - sensitive.

- import and declare a Scanner class

- declare three floating – point variables named price, discount, and discountPrice

- ask the user for the price (print statement) and get the price (Scanner) from the user

- calculate the discount if price is less than 100, then the discount is 10% of price, else discount is 14% of price

- print the discounted prices for the item

 

Sample Run

Enter the price

90.0

The discount price is 81.0

 

Enter the price

200.0

The discount price is 172.0

check_circleExpert Solution
Step 1

The program has the following steps:

  1. Declare the variables
  2. Receive the input from the user
  3. Calculate the discount based on conditions
  4. Display the discounted price
Step 2

The java program is shown below:

import java.util.Scanner;

public class Sales{

            public static void main(String args[]){

                        float price, discount, discountPrice;

                        //read user input

                        Scanner reader = new Scanner(System.in);

                        System.out.println("Enter a price:");

                        price = reader.nextFloat();

                        //calculate the discounted price

                        if (price < 100){

                                  &n...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour*

See Solution
*Response times may vary by subject and question
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: You are not required to execute the queries. However, your syntax must by accurate.You must give at ...

A: Hey, since there are multiple sub-part questions posted, we will answer first three questions. If yo...

question_answer

Q: function myCompose(f,g){// TODO: return (f o g);// that is, a function that returns f(g(x)) wh...

A: Click to see the answer

question_answer

Q: Assume that you have been tasked by your employer to develop an incident response plan. Create a lis...

A: Stakeholder:A stakeholder can be a person, a group, or an organization that has an affair or matter ...

question_answer

Q: For this program you need to use Eclipse

A: Program plan:Declare the integer variables “coin” and “guess” and string variable “num”.Generate the...

question_answer

Q: Design a modular program that asks the user to enter the monthly costs for the following expenses in...

A: We are designing the program in C++ programming language. Given below is the program designed to ent...

question_answer

Q: I am working on creating a logical entity relationship diagram for my database class. I am wondering...

A: Although the full problem description is not given so deducing the problem / requirements from the d...

question_answer

Q: How do you perform in Access?

A: MS Access is a database management system through which you can create, manipulate, maintain and del...

question_answer

Q: create a python program that will ask users to input four different manufacturers of cars(e.g Ford, ...

A: Create a class Car and define _init_ () function which will initialize the value of variables manufa...

question_answer

Q: what are some of the challenges that can face a firm to combine “a clear brand vision with a common ...

A: Introduction:The combination of clear brand vision of an organization with a common operating model ...