3. WAP IN JAVA TO INPUT PURCHASE AMOUNT FROM THE USER AND CALCULATE DISCOUNT AMOUNT FROM ON THE BASIS OF THE FOLLOWING :
IF PURCHASED AMOUNT IS UPTO Rs. 500 , DISCOUNT IS 10%
IF PURCHASED AMOUNT IS >Rs. 500 , BUT LESS THAN Rs.1000,
DISCOUNT IS 20%
IF PURCHASED AMOUNT IS IS GREATER THEN Rs. 1000 ,
DISCOUNT IS 30%
DISPLAY NETAMOUNT SHOULD PAY BY THE CUSTOMER .
import java.util.*; //import java packages
class Prog //declare the class
{
public static void main(String args[ ]) // “main” method
{
Scanner ob=new Scanner(System.in);
double pamt,discount,netamt; //declare the variable
System.out.print(“Enter Purchased Amount”); //input the value
pamt=ob.nextDouble( ) ;
if(pamt<=500)
discount=pamt*(10/100);
if((pamt>500) && (pamt<1000))
discount=pamt*(20/100);
if(pamt>=1000)
discount=pamt*(30/100);
netamt=pamt-discount;
System.out.prinln(“Net Amount payable”+discount); //display Discount Amount
System.out.prinln(“Net Amount payable”+netamt); //display Net Amount
} //end of “main”
} //end of class