Question

Make a Java program. Below is the expected output. Enter the units sold: 0 Units sold:...

Make a Java program. Below is the expected output.


Enter the units sold: 0
Units sold: 0
Discount: $0.00
Cost: $0.00

Enter the units sold: 5
Units sold: 5
Discount: $0.00
Cost: $495.00

Enter the units sold: 10
Units sold: 10
Discount: $198.00
Cost: $792.00

Enter the units sold: 15
Units sold: 15
Discount: $297.00
Cost: $1,188.00

Enter the units sold: 25
Units sold: 25
Discount: $742.50
Cost: $1,732.50

Enter the units sold: 55
Units sold: 55
Discount: $2,178.00
Cost: $3,267.00

Enter the units sold: 100
Units sold: 100
Discount: $4,950.00
Cost: $4,950.00

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is code:

import java.util.*;

public class CalculatePrice {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter the units sold: ");

int qty = sc.nextInt();

System.out.println("Units sold: " + qty);

double total = qty * 99;

double discount = 0;

if (qty <= 20) {

discount = total * 0.20;

} else if (qty <= 30) {

discount = total * 0.30;

} else if (qty <= 60) {

discount = total * 0.40;

} else if (qty <= 100) {

discount = total * 0.50;

}

double cost = total - discount;

System.out.println("Discount: $" + discount);

System.out.println("Cost: $" + cost);

}

}

Output:

Add a comment
Know the answer?
Add Answer to:
Make a Java program. Below is the expected output. Enter the units sold: 0 Units sold:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Provide the expected output AS IT WOULD APPEAR IN A JAVA PROGRAM as the result of a print statement. (i.e. Enter true or...

    Provide the expected output AS IT WOULD APPEAR IN A JAVA PROGRAM as the result of a print statement. (i.e. Enter true or false (all lower case letters). If you enter TRUE, F, True, etc these will be marked wrong). Given the following declarations: int x = 25; int y = -4; int z = 17; boolean b = false; What would be the output of the following Boolean expressions? (x % 2 != 0) && b b && !b...

  • Please make a JAVA program for the following using switch structures Write a program that simulates...

    Please make a JAVA program for the following using switch structures Write a program that simulates a simple Calculator program. The program will display menu choices to the user to Add, Subtract, Multiply and Divide. The program will prompt the user to make a selection from the choices and get their choice into the program. The program will use a nested if….else (selection control structure) to determine the user’s menu choice. Prompt the user to enter two numbers, perform the...

  • <Program 1: 50 points> software.cpp A software company sells a package that retails for $99. Quantity...

    <Program 1: 50 points> software.cpp A software company sells a package that retails for $99. Quantity discounts are given according to the following table. Quantity Discount 10-19 20% 20-49 30% 50-99 40% 100 or more 50% Write a program that asks for today's date (you MUST use cin >> date. Do not use getline(cin, date)), the company name and the quantity they wish to buy and computes the total cost of the purchase. If the user enters a negative value...

  • Part II – Cost Calculator (15 Points) A software company sells a package that retails for...

    Part II – Cost Calculator (15 Points) A software company sells a package that retails for $ 99. Quantity discounts are given according to the following table: Quantity Discount 10 to 19 20% 20 to 49 30% 50 to 99 40% 100 or more 50% Write a program that asks the user to enter the number of packages purchased. The program should then display the discount percentage, amount of the discount (can be 0) and the total amount of the...

  • Write a Java program to prompt for inputting an integer N, then enter N integers (a...

    Write a Java program to prompt for inputting an integer N, then enter N integers (a loop is needed), print the numbers user entered, and the amount of even and odd numbers (zero is even number). (1) Prompt for the user to input an integer and output the integer. (1 pts) Enter an integer: You entered: 5 (2) Prompt for the user to input N integers, output the numbers entered and the amount of even and odd numbers (9 pts)...

  • Exercise #3: write a Java program that prompts the user to enter a sentence. The program...

    Exercise #3: write a Java program that prompts the user to enter a sentence. The program has to find the print: a. the position of vowels in the sentence. b. the number of vowels in the sentence (A, a, U, u, E, e, O, o, I, i) c. the number of characters as numbers or special characters (other than English letters a.z, A..Z). Hint: remember to ignore the spaces. Sample input-output: Enter the sentnse: UAEU is the university of the...

  • In Java with comments. Write a program that computes the cost of flowers sold at a...

    In Java with comments. Write a program that computes the cost of flowers sold at a flower stand. Five kinds of flowers—petunia, pansy, rose, violet, and carnation— are stocked and cost, respectively, 50¢, 75¢, $1.50, 50¢, and 80¢ per flower. Create an array of strings that holds the names of these flowers. Create another array that holds the cost of each corresponding flower. Your program should read the name of a flower and the quantity desired by a customer. Locate...

  • Write a program in Java that simulates a vending machine: The vending machine sells three types...

    Write a program in Java that simulates a vending machine: The vending machine sells three types of food: 1) Potato chips $1.25; 2) Cookies $0.85; 3) Candies $0.95. The program will prompt for the buyer to enter the amount in quarters (25 cents), dimes (10 cents), and nickels (5 cents). The program will then present a selection menu for the foods and prompt the buyer to enter the amount of quarters, dimes and nickels. The machine would then proceed to...

  • Write a Java program (code + screenshot of output) that takes a user input temperature and...

    Write a Java program (code + screenshot of output) that takes a user input temperature and displays an output as follows: Temperature Output temperature > 40 Hot 40 ≥ temperature > 25 Warm 25 ≥ temperature > 15 Nice 15 ≥ temperature Cold Sample run1: Please input the temperature: 45 Hot Sample run2: Please input the temperature: 40 Warm Sample run3: Please input the temperature: 20 Nice Sample run4: Please input the temperature: 5 Cold Sample run5: Please input the...

  • C++ program by netBeans java language Exercise #2: Write a java program that prompts the user...

    C++ program by netBeans java language Exercise #2: Write a java program that prompts the user to enter a sentence. The program has to find the print: a. the position of vowels in the sentence. b. the number of vowels in the sentence (A, a, U, u, E, e, 0, o, I, i) c. the number of characters as numbers or special characters (other than English letters a..z, A..Z). Hint: remember to ignore the spaces. Sample input-output: Enter the sentnse:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT