ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2007 ICSE Computer Science Paper



Share with a Friend

Solved 2007 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Salary Calculation Program - ICSE 2007 Computer Science

Define a class Salary described as below:
Data members:
name, address, phone, subject specialization, monthly salary, income tax.
Methods:
i) to accept the details of a teacher including the monthly salary.
ii) to display the details of the teacher.
iii) to compute the annual income tax as 5% of the annual salary above Rs. 1,75,000.
Write a main() method to create an object of the class and call the above methods accordingly.

import java.io.*; class Salary{ String name; String address; int phone; String subject; double salary; double tax; public void input()throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Name: "); name = br.readLine(); System.out.print("Address: "); address = br.readLine(); System.out.print("Phone Number: "); phone = Integer.parseInt(br.readLine()); System.out.print("Subject: "); subject = br.readLine(); System.out.print("Monthly salary: "); salary = Double.parseDouble(br.readLine()); } public void compute(){ tax = 5.0 / 100 * (salary * 12 - 175000.0); } public void display(){ System.out.println("Name: " + name); System.out.println("Address: " + address); System.out.println("Phone: " + phone); System.out.println("Subject: " + subject); System.out.println("Monthly Salary : Rs. " + salary); System.out.println("Annual income tax: Rs. " + tax); } public static void main(String args[])throws IOException{ Salary obj = new Salary(); obj.input(); obj.compute(); obj.display(); } }

Output

 
 OUTPUT 1: 
Name: Anand
Address: Bangalore
Phone Number: 123456
Subject: Maths
Monthly salary: 15000

Name: Anand
Address: Bangalore
Phone: 123456
Subject: Maths
Monthly Salary : Rs. 15000.0
Annual income tax: Rs. 250.0