write a program in java to input the amount of purchase and calculate the discount as per the following criteria:
Purchase Amount. Discount
from 1 up to 1000 = nil
above 1000 up to 5000 =10%
above 5000 = 20%
Answers
Answered by
35
import java.util.Scanner;
class Input
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int discount=0;
System.out.print("Enter amount: ");
int number = input.nextInt();
if(number<=1000)
{
discount=0;
}
else if(number<=5000 && number>1000)
{
discount=(number*10)/100;
}
else if (number>5000)
{
discount=(number*20)/100;
}
System.out.println("Amount " +number);
System.out.println("Discount " +discount);
}
}
Edit : Sorry for some errors. Corrected now!
If you find your answer the mark me as brainliest! Thank you.
Similar questions
Math,
6 months ago
English,
6 months ago
World Languages,
1 year ago
Political Science,
1 year ago
Science,
1 year ago