-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSalary.java
More file actions
59 lines (53 loc) · 2.02 KB
/
Copy pathSalary.java
File metadata and controls
59 lines (53 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Define a class salary described as below :
// Data Members: Name, Address, Phone, Subject Specialisation, Monthly Salary, Income Tax.
// Member 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 object of a class and call the above member method. [15]
import java.io.*;
class Salary {
String name, address, phone, subject;
double salary, it;
void get(String na, String add, String ph, String sub, double sal) {
name = na;
address = add;
phone = ph;
subject = sub;
salary = sal;
}
void display() {
System.out.println("Name=" + name);
System.out.println("Address=" + address);
System.out.println("Phone Number =" + phone);
System.out.println("Subject Specialization =" + subject);
System.out.println("Monthly Salary=" + salary);
System.out.println("Income Tax=" + it);
}
void compute() {
if ((salary * 12) > 175000)
it = 0.05 * (salary * 12);
else
it = 0;
}
public static void main(String[] args) throws IOException {
InputStreamReader IR = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(IR);
salary obj = new salary();
String na, add, ph, sb;
double sal;
System.out.print("Enter the name");
na = br.readLine();
System.out.print("Enter the Address");
add = br.readLine();
System.out.print("Enter the Phone Number");
ph = br.readLine();
System.out.print("Enter the Subject Specialization");
sb = br.readLine();
System.out.print("Enter the Monthly Salary");
sal = Double.parseDouble(br.readLine());
obj.get(na, add, ph, sb, sal);
obj.compute();
obj.display();
}
}