Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**LANGUAGE: JAVA ONLY** **USE THE SCANNER CLASS FOR INPUT AND SYSTEM.OUT.PRINTIN

ID: 3915080 • Letter: #

Question

**LANGUAGE: JAVA ONLY**

**USE THE SCANNER CLASS FOR INPUT AND SYSTEM.OUT.PRINTIN OR SYSTEM.OUT.PRINT**

**USE IF-ELSE-IF STATEMENT, NOT IF-ELSE STATEMENT**

8. Software Sales A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Quantity 10-19 20-49 50-99 100 or more Discount 20% 30% 40% 50% Write a program that asks the user to enter the number of packages purchased. The pro- gram should then display the amount of the discount (if any) and the total amount of the purchase after the discount.

Explanation / Answer

package hello;

import java.util.*;

public class Hi {

public static void main(String args[])

{

System.out.println("Package cost is $99");

Scanner s=new Scanner(System.in);

System.out.println("Enter quantity:");

int b=s.nextInt();

if(b>=10 && b<=19)

{

int k=b*99;

int discount=(k)*20/100;

System.out.println("quantity:"+ b);

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

System.out.println("Total amount:"+ (k-discount));

}

else if(b>=20 && b<=49)

{

int k=b*99;

int discount=(k)*30/100;

System.out.println("quantity:"+ b);

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

System.out.println("Total amount:"+ (k-discount));

}

else if(b>=50 && b<=99)

{

int k=b*99;

int discount=(k)*40/100;

System.out.println("quantity:"+ b);

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

System.out.println("Total amount:"+ (k-discount));

}

else

{

if (b>=100)

{

int k=b*99;

int discount=(k)*50/100;

System.out.println("quantity:"+ b);

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

System.out.println("Total amount:"+ (k-discount));

}

}

}

}

Please comment below if you have any doubts