Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class and a Java program to use the class. Part 1. Create a class called

ID: 3843115 • Letter: W

Question

Write a class and a Java program to use the class. Part 1. Create a class called Incomo that contains the following: 1. Two (2) instance variables: a double called "incomeYTD" and double called "hourlyRate" The class should also include the following methods: 2. a constructor that receives 2 double parameters; the constructor will use these parameters to initialize the incomeYTD and the hourlyRate respectively. 3. setincomeYTD: it receives a double parameter and assigns it to the incomeYTD. 4. getincomeYTD: it returns the incomeYTD value 5. calculateincome: it receives a double parameter and calculates and returns the current income amount for the current hourly rate (income = hourlyRate times workingHours)

Explanation / Answer

java program using class Income is:
public class Income
{
public double incomeYTD;
public double hourlyRate;
Income(double incomeYTD,double hourlyRate)
{
this.incomeYTD=incomeYTD;
this.hourlyRate=hourlyRate;
}
public void setincomeYTD( double income ) {
incomeYTD = income;
}
public double getincomeYTD()
{
   return incomeYTD;
}
public double calculateIncome(double workinghours)
{
   double income=hourlyRate*workinghours;
   return income;
}


   public static void main(String[] args)
{
      
Income in=new Income(234.45,12.34);
in.setincomeYTD(234.52);

System.out.println("incomeYTD="+in.getincomeYTD());
System.out.println("income after calculation is="+in.calculateIncome(14.72));

   }

}

the output for above program is

incomeYTD=234.52

income after calculation is=181.6448.

the instance variables incomeYTD and hourlyRate are accessed by invoking aobject of the class Income.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote