# Thread: Incompatible types Integer Boolean

1. Member Join Date
Mar 2014
Posts
1
Rep Power
0

## Incompatible types Integer Boolean

I am trying to write a program to calculate the monthly amount paid for a mortgage and the total amount but i keep getting this errors Attachment 5998

This is my program:

import static java.lang.Math.pow;
import java.io.*;
import java.util.*;

class MyInput

{ static private StringTokenizer stok;

{ int i = 0;
try
StringTokenizer stok = new StringTokenizer (str);
i = new Integer (stok.nextToken ()).intValue ();
}
catch (IOException e)
{ System.out.println(e); }

return i;
}

{ double d = 0;
try
stok = new StringTokenizer (str);
d = new Double (stok.nextToken ()).doubleValue ();
}
catch (IOException e) { System.out.println(e); }
return d;
}
}

public class MortgagePayments{

public static void main(String[]args)

double interest_rate;
int year=0;
double loan;
double monthly_payment;
double total;
int yearopt1=7;
int yearopt2=15;
int yearopt3=30;
int val;

System.out.println("Please enter the loan amount: ");

if(year=yearopt1)
interest_rate=7.25;

else if (year=yearopt2)

interest_rate=8.5;

else if(year=yearopt3)

interest_rate=year*9;

val=year+12;
monthly_payment=((loan*interest_rate)/(1-(Math.pow(1+interest_rate,val))));
total=monthly_payment*year*12;

System.out.println("The montly payment will be: " +monthly_payment);
System.out.println("The total amount you will pay will be: " +total);

}//main ends

}//class ends  Reply With Quote

2. ## Re: Incompatible types Integer Boolean

If you want to compare two ints you use ==. With a single = you assing the value.  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•