Trending ▼   ResFinder  

ICSE If else Programs 2018 : Computer Applications

16 pages, 13 questions, 0 questions with responses, 0 total responses,    0    0
Manasa Preethi
Sikkim manipal university, Bangalore
Master of Science Information Technology
+Fave Message
 Home > manumansi >

Formatting page ...

BASIC JAVA PROGRAMS 1. An electronics shop has announced the following seasonal discounts on the purchase of certain items. Purchase Amount in Rs. Discount on Laptop Discount on Desktop PC 0 25000 0.0% 5.0% 25001 57000 5.0% 7.6% 57001 100000 7.5% 10.0% More than 100000 10.0% 15.0% Write a program based on the above criteria to input name, address, amount of purchase and type of purchase (L for Laptop and D for Desktop) by a customer. Compute and print the net amount to be paid by a customer along with his name and address. (Hint: discount = (discount rate/100)* amount of purchase Net amount = amount of purchase discount) Solution: import java.io.*; public class Electronics { public static void main(String[] args)throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter name: "); String name = br.readLine(); System.out.print("Enter address: "); String address = br.readLine(); System.out.print("Enter type of purchase: "); String type = br.readLine(); System.out.print("Enter amount of purchase: "); int amount = Integer.parseInt(br.readLine()); double discountRate = 0.0; if (type.equals("L")) { if (amount <= 25000) discountRate = 0; else if (amount >= 25001 && amount <= 57000) discountRate = 5.0; else if (amount >= 57001 && amount <= 100000) discountRate = 7.5; else if (amount > 100000) discountRate = 10.0; } else if (type.equals("D")) { if (amount <= 25000) discountRate = 5.0; else if (amount >= 25001 && amount <= 57000) discountRate = 7.6; else if (amount >= 57001 && amount <= 100000) discountRate = 10.0;

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

 

  Print intermediate debugging step

Show debugging info


 

 

© 2010 - 2024 ResPaper. Terms of ServiceContact Us Advertise with us

 

manumansi chat