ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2010 ICSE Computer Science Paper



Share with a Friend

Solved 2010 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Ticket Discount Program - ICSE 2010 Computer Science

Shasha Travels Pvt. Ltd. gives the following discount to its customers:
Ticket Amount                        Discount
Above Rs. 70000                     18%
Rs. 55001 to Rs. 70000           16%
Rs. 35001 to Rs. 55000           12%
Rs. 25001 to Rs. 35000           10%
Less than Rs. 25001               2%

Write a program to input the name and ticket amount for the customer and calculate the discount amount and net amount to be paid. Display the output in the following format for each customer:
SNo.    Name    Ticket charges    Discount    Net amount
____     ______    _______________    _________     ____________
Assume that there are 15 customers, first customer is given the serial number 1, next customer 2… and so on.

import java.util.Scanner; class Travel{ public static void main(String args[]){ Scanner in = new Scanner(System.in); System.out.print("Name: "); String name = in.nextLine(); System.out.print("Ticket amount: "); double amt = Double.parseDouble(in.nextLine()); double dp = 0.0; if(amt > 70000) dp = 18.0; else if(amt > 50000) dp = 16.0; else if(amt > 35000) dp = 12.0; else if(amt > 25000) dp = 10.0; else dp = 2.0; double d = dp / 100 * amt; double net = amt - d; System.out.println("Sl.No. Name Ticket Charges Discount Net amount"); System.out.println("1. " + name + " " + amt + " " + d + " " + net); } }

Output

 
 OUTPUT  : 
Name: Ricky
Ticket amount: 75000
Sl.No.   Name      Ticket Charges   Discount    Net amount
1.         Ricky        75000.0           13500.0    61500.0