Define a class Salary as discussed below
Define a class Salary as discussed below :
Use Name,address,phone,subject spcialization,montly salary,income tax.
Member methods (i)To accept the details of a teacher including monthly salary (ii)To display the details of the teacher(iii)To compute the annual income tax as 5% of the annual salary aboveRs175000.Write a main method to create object of a class &call the above member method. import java.util.*;
class salary
{
String name,add,subsp; long phoneno; double monsal;
public void getdata()
{
Scanner Sc=new Scanner(System. in);
double inctax;
System.out.println("Enter name, address, phone no. ,subspec. and monthsal.");
name=Sc.next();
add=Sc.next();
phoneno=Sc.nextlong();
subsp=Sc.next();
monsal=Sc.nextDouble();}
public void calculate()
{
if(monsal>175000)
{ inctax=0.05*monsal;}
else
{ inctax=0;}
public void display()
{
System.out.println("Name:"+name);
System.out.println("Address:"+add);
System.out.println("Phone no:"+phoneno);
System.out.println("Subject Specialisation:
System.out.println("Monthly salary:"+monsal);
System.out.println(“Income tax:”+nctax); }
public static void main()
{
salary obj=new salary();
obj.getdata();
obj.calculate();
obj.display();
}}
Name: Man
Address: hjhj
Phone no.: 000908080808
Subject Specialization: Mathematics
Monthly salary: 5000
Annual salary: 60000
Income tax: 0
Thanks for viewing "Define a class Salary as discussed below ...
----------------------------------------------------------------------------------------------------------------
Just copy paste the code into the class file of Bluej compiler. Change the class name according to your's.
Thanks for visting Programming in JAVA
Happy Coding !!
Very wrong program
ReplyDeletePlease point out the mistake.
ReplyDelete