The questions are at the bottom of the code.
Need Java Help! I don't know what I'm doing or where to start!?
Here is the first program:

public class IntClass
{
private int x;

public IntClass()
{
x = 0;
}
public IntClass(int num)
{
x = num;
}

public void setNum(int num)
{
x = num;
}

public int getNum()
{
return x;
}

public void addToNum(int num)
{
x = x + num;
}

public void multiplyToNum(int num)
{
x = x * num;
}

public int compareTo(int num)
{
return (x - num);
}

public boolean equals(int num)
{
if (x == num)
return true;
else
return false;
}

public String toString()
{
return (String.valueOf(x));
}
}

Second Program

public class CharClass
{
private char ch;

public CharClass()
{
ch = ' ';
}

public CharClass(char c)
{
ch = c;
}

public void setChar(char c)
{
ch = c;
}

public int getChar()
{
return ch;
}

public char nextChar()
{
return (char)((int)ch + 1);
}

public char prevChar()
{
return (char)((int)ch - 1);
}

public String toString()
{
return (String.valueOf(ch));
}
}

This is what I have to do:
Consider the following program segment (with the method main):

public class CH7_Exercise9
{
public static void main (String[] arg)
{
IntClass x,y;
CharClass z;

double rate;
double hours;
double amount;
.
.
.
}
}
Write the following definitions:

a. Write the definitions of the method initialize that initialized x and y to 0 and initializes z to the blank character.
b. Write a definition of the method getHoursRate that prompts the user to input the hours worked and rate per hour to initialize the variable hours and rate of the method main.
c. Write the definition of the value-returning method payCheck that calculates and returns the amount to be paid to an employee, based on the hours worked and rate per hour.
The hour are stored in the variables hours and rate, respectively, of the method main. The formula for calculating the amount to be paid is as follows: for the first 40 hours,
the rate is given rate; for hours over 40, the rate is 1.5 times the given rate.
d. Write the definition of the method printCheck that prints the hours worked, rate per hour, and the amount due.

This article has been dead for over six months. Start a new discussion instead.