Computer Science, asked by sharvandu, 5 months ago

Write a program in Java to calculate discount from the amount and display discount amount. Using else-if​

Attachments:

Answers

Answered by kamalrajatjoshi94
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