Gordan Lee

Greenhorn
+ Follow
since Oct 02, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Gordan Lee

Here is my code: (it compiles fine and runs but i need to know if i am doing the assignment correctly. thanks)
public class Date
{
private int day;
private int month;
private int year;

public Date()
{

day = 0;
month =0;
year = 0;
}

public Date(int day, int month, int year)

{
this.day = day;
this.month = month;
this.year = year;
}

public int getMonth()
{
return month;
}

public int getDay()
{
return day;
}

public int getYear()
{
return year;
}


public void setMonth(int month)
{
this.month = month;
}

public void setDay(int day)
{
this.day = day;
}

public void setYear(int year)
{
this.year = year;
}


public String toString()
{
String report;
report = "+ month / + day / + year";
//report = report + "+ day";
//report = report + "+ year";
return report;
}

public boolean equals(Date anotherDate)

{
boolean isEqual;
isEqual = ((day == anotherDate.getDay()) &&
(month == anotherDate.getMonth()) &&
(year == anotherDate.getYear()));


return isEqual;


}

}
21 years ago
i have a class month, day and year
my toSring() is
public String toString()
{
String report;
report = "+ month / + day / + year";
//report = report + "+ day";
//report = report + "+ year";
return report;
}
i take out the 2 lines of // because the assignment asks me to do
toString(): String [in the format of mm/dd/yyyy
is my toString method correct? thanks.
21 years ago
thank you guys for the help.
21 years ago
HELP!!
------

//calcualte principal
double principal = monthlyInterestRate - interest;


//calculate interest
monthlyInterestRate = annualInterestRate / 1200;

interest = monthlyInterestRate * principal;


//calcualte balance
balance = loanAmount - principal;

------------
--------------------Configuration: j2sdk1.4.0_03 <Default>--------------------
D:\xxxx\xxx.java:40: variable monthlyInterestRate might not have been initialized
double principal = monthlyInterestRate - interest;
^
D:\xxx\xxx.java:40: variable interest might not have been initialized
double principal = monthlyInterestRate - interest;
^
2 errors
Process completed.
---------------------------
[ October 02, 2003: Message edited by: Gordan Lee ]
21 years ago
public class xxx
{
public static void main(String[] args)
{

System.out.print("Loan Amount: ");
double loanAmount = MyInput.readDouble();

System.out.print("Number of Years: ");
int numOfYears = MyInput.readInt();

System.out.print("Interest Rate: ");
int interestRate = MyInput.readInt();

System.out.println("Payment\t\tInterest\t\tPrincipal\t\tBalance");
System.out.println("-------------------------------------------------------------");

double payment;
double monthlyInterestRate;
double remainingPrincipal;
int paymentNum;
double interest;
double annualInterestRate;
double balance;

//payment #
//numOfYears = paymentNum * 12;



for (numOfYears = paymentNum * 12)
{
//calculate interest
monthlyInterestRate = annualInterestRate / 1200;

interest = monthlyInterestRate * remainingPrincipal;

//calcualte principal


//calcualte balance


System.out.println(paymentNum+"%\t\t\t"+interest+"\t\t\t"
+remainingPrincipal+"\t\t\t"+balance);

}
}
}


--------------
i know. its a mess. the codes are not done.
21 years ago
Writing this exercise program for my class and I'm a mess. Please help out, any tips appreciated. I can post my codes that has errors if needed. Thanks.
I am supposed to write a program that let the user enter
loan amount:
number of years:
interest rate:
then the output is
payament # interest prncipal balance
1 58.33 806.93 9193.07
2
3
.
.
.
12
THANKS!! any tip will help.
21 years ago