Write a program to input the code of a particular item, the quantity purchased and the rate. Then ask if any more items are to be purchased. If not, then calculate the total purchase and print it along with the gift to be presented. The gifts to the customers are given in the following manner: Amount of purchase(Rs.) Gift 100 and above but less than 500 A key ring 500 and above but less than 1000 A leather purse 1000 and above A pocket calculator Before ending the program a ‘Thank You’ statement should be printed to all the customers.
Answers
Answered by
3
Answer:
public class Q1
{
public static void main(String args[])throws IOException
{
InputStreamReader read =new InputStreamReader(System.in);
BufferedReader in =new BufferedReader(read);
int p; double SI1,SI2,SI3,A3;
System.out.println(“Enter the principal”);
p=Integer.parseInt(in.readLine());
SI1=(p*5.0*1)/100.0;
System.out.println(“Interest for the first year =”+SI1);
SI2=((p+SI1)*5.0*1)/100.0;
System.out.println(“Interest for the second year =”+SI2);
SI3=((SI1+SI2+p)*5.0*1)/100;
A3=SI1+SI2+SI3+p;
System.out.println(“Amount after three years =”+A3);
}
}
Sample Input: 10000
Sample Output: Interest for the first year =500.0
Interest for the second year =525.0
Amount after three years =11576.25
Similar questions