DEAR FRIENDS, I M NEW TO JAVA,
PLEASE ANSWER MY QUESTIONS:
1. I am trying to use float and double in java? can u tell me how to use it?
2. I am trying to calculate simple interest in java ?
please fix my code:
public class simple
{
public static void main (String[] args)
{
// this program calculates the simple interest.
int principal, noy;
double rate, si;
principal = 1000;
noy = 3;
rate = 2.5;
si = (principal * noy * rate) /1000;
System.out.printf (" The principal is %d \n number of years: %d, \nrate is: %lf \n The calculated simple interest is:%lf\n ", principal,noy,rate,si);
}
}
the code has error i know. %lf doesnt work.
please fix this.