Need help fixing my java coding has a few little errors I cant fix for some reas
ID: 3585211 • Letter: N
Question
Need help fixing my java coding has a few little errors I cant fix for some reason or figure out wht it is doing that.
A software company sells a package that retails for $99. Quantity discounts are given according to the following table.
Quantity Discount
10 - 39 10%
40 - 65 18%
66 - 90 27%
91 - 120 35%
121 – 199 42%
200 or more 48%
Write a program that asks for the number of units sold (validate the data) and computes the total cost of the purchase and the savings due to the discount applied. The program should also display the number of units purchased and the discount in percentage. The output should include the following text: Number of units purchased is: Discount applied is: Total savings due to discount is: The total cost of the purchase is: Do NOT use a logical operator in the program.
Run your program three times with 5, 66, and 210 as the user input for the number of units purchased.
de) FrankVoelker Program5.java 3 2 public class FrankVoelker_Program5 // declare variables int units; double discount, totalPrice, savings, finalPrice; // price per unit given 8 int price 99; 10 // ask for user input 011System.out println("Enter number of units purchased " 012 units = in.nextInt(); 13 14 15 166 17 18 19 // input validation, for invalid input repeat input while (units 0) System.out.println(" Enter number of units purchased : "); units = in.nextInt(); // calculate discount% based on input for "units" if (units >-200) discount48; else if (units>121) discount 42; else if (units>- 91) discount 35; 25 26 else if (units 66 discount -27; 29 30 else if (units 40 discount 18 Problems Javadoc Declaration 3Explanation / Answer
Hi
The issue here is that Scannner class object institalization is missing. With out Scanner object you can not read the value from Console.
Please add this statement after 5th line in your code. Then Compilation errors will be gone.
Scanner in = new Scanner(System.in);
you have import Scanner class from java.util.Scanner;
Place below statement at the bigining of the program
import java.util.Scanner;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.