Could anyone tell where is the error in the program? There is a compile-time error... When I hit compile it shows error in the 40th line saying that 'r' might not have been initialised.. I can't get that.. Pease could anybody help??
import java.util.Scanner;
public class Customer_Account
{
public static void main(String args[])
{
Scanner in= new Scanner(System.in);
int dep, n, money=0;
int r;
System.out.println("Enter the amount deposited");
dep= in.nextInt();
System.out.println("Enter the number of years");
n= in.nextInt();
if(dep<2000 && n>=2)
{
r=5;
money=(dep*r*n)/100;
}
if(dep>=2000 && dep<6000 && n>=2)
{
r=7;
money=(dep*r*n)/100;
}
if(dep>6000 && n>=1)
{
r=8;
money=(dep*r*n)/100;
}
if(n>=5)
{
r=10;
money=(dep*r*n)/100;
}
if((dep<2000 && n>=2)&&(dep>=2000)&&(dep<6000 && n>=2)&&(dep>6000 && n>=1)&&(n>=5))
{
r=3;
money=(dep*r*n)/100;
}
System.out.println("Money deposited= Rs."+ dep);
System.out.println("Time Period="+" " +n+"years");
System.out.println("Rate Of Interest="+ r + "%");
System.out.println("Amount In Account= Rs."+ money);
}
It would be great if I get the help before monday the 26th coz my computer exam is on that day..So obviously I need it before that!!!
Thanks, Ordella.