Write a program in Java to calculate discount from the amount and display discount amount. Using else-if
Attachments:
Answers
Answered by
5
Answer:
import java.util.*;
public class Amount
{
public static void main(String args[])
{
Scanner in=new Scanner(System.In);
int price;
double amt;
String name;
System.out.println("Enter the name");
name=in.next();
System.out.println("Enter the price");
price=in.nextInt();
if(price>0&&price<=1500)
{
amt=price-(10.0/100.0*price);
}
else if(price<=5000)
{
amt=price-(20.0/100.0*price);
}
else if(price<=15000)
{
amt=price-(32.5/100.0*price);
}
else
{
amt=price-(40.0/100.0*price);
}
System.out.println("Name="+name);
System.out.println("Amount purchased="+price);
System.out.println("Discounted amount="+amt);
}
}
Similar questions
English,
2 months ago
Math,
2 months ago
Math,
2 months ago
Social Sciences,
5 months ago
Social Sciences,
5 months ago
Political Science,
11 months ago
Economy,
11 months ago