import java.io.*;
import java.lang.*;
import java.util.*;


class CustomerInfo
{
	public String name = new String();
	public String accnNumber =new Sting();
	public String accnType = new String();
	public float balance = 0.0F;
	public float rateOfInterest =0.0F;
	public float interest = 0.0F;
	public float useBalance = 0.0F;
	public String password = new String();

	void input()
	throws IOException
	{
		System.out.println("Please Enter information");
		System.out.print("Enter Name :");
		DataInputStream input = new DataInputStream(System.in);
		name = input.readLine();
		System.out.println();
		System.out.print("Enter Account Number : ");
		accnNumber = input.readLine();
		System.out.println();
		System.out.print("Enter Balance: Rs.");
		balance = Float.parseFloat(input.readLine());
		System.out.println();
		System.out.print("Assign a password that you can remember");
		password = input.readLine();
		System.out.println();
	}
}


class Transactions extends CustomerInfo
{
	float wthdrw = 0.0F;
	float dpst = 0.0F;
	
	void withdraw()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		System.out.println("You current opening balance is Rs." + useBalance);
		System.out.print("Enter the amount to withdraw : Rs.");
		wthdrw = Float.parseFloat(input.readLine());
		System.out.println();
		useBalance-= wthdrw;
		System.out.println("The closing balance after withdrawal is Rs." + useBalance);
	}
	void deposit()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		System.out.print("Enter the amount to deposit : Rs.");
		dpst=Float.parseFloat(input.readLine());
		useBalance+= dpst;
		System.out.println();
		System.out.println("The closing balance after this deposit is Rs."+ useBalance);
	}
	void calcInterest(float useBalance,float rateOfInterest, boolean ans)
	throws IOException
	{
		interest = (useBalance*rateOfIntrest)/100;
		System.out.print("Interest per month is Rs"+interest);	
		System.out.print("Do you want to see the current usable balance when added to yearly income?Y/N");
		if((input.read())=='Y')
			 ans = true;
		if(ans==true)
			System.out.println("The amount after one annum will become Rs."+(useBalance+(12*interest)));
		else
			System.out.println("Thank you");
	}
}


class SavingsAccount extends Transaction
{
	public SavingsAccount()
	{
		final float minBalance = 5000;
		useBalance = balance-minBalance;
		accnType = "Savings";
		rateOfInterest1 = 10;
	}
	
	void actions()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		
		SavingsAccount sAccount[]=new SavingsAccount[1000];
                          do
		{
			System.out.println("What do want to do?");
			System.out.println("1.Withdraw");
			System.out.println("2.Deposit");
			i=1;
                            	SavingsAccount sAccount[i]=new SavingsAccount();
			if((input.read())=='1')
				sAccount[i].withdraw();
			else if((input.read())=='2')	
				sAccount[i].deposit();
		}while((input.read())!='1'||(input.read())!='2');
		System.out.println("Do you want to see the interest?Y/N");
		if((input.read())=='Y')
			sAccount[i].calcInterest(useBalance,rateOfInterest,true);
		else
			System.out.println("Thank you.");

	}
}

class CurrentAccount extends Transaction
{
	public CurrentAccount()
	{
		final float minBalance2 = 3000;
		useBalance = balance-minBalance2;
		accnType = "Current";
		rateOfInterest2 = 2;
	}

	void actions()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		do
		{
			System.out.println("What do want to do?");
			System.out.println("1.Withdraw");
			System.out.println("2.Deposit");
			if((input.readLine())==1)
				cAccount[j].withdraw();
			else if((input.readLine())==2)	
				cAccount[j].deposit();
		}while((input.read())!='1'||(input.read())!='2');
		System.out.println("Do you want to see the interest?Y/N");
		if((input.read())=='Y')
			cAccount[j].calcInterest(useBalance,rateOfInterest2,true);
		else
			System.out.println("Thank you.");

	}
}

class BankHQ
{
	public static void main(String args[])
	throws IOException
	{
		SavingsAccount sAccount[] = new SavingsAccount[1000];
		CurrentAccount cAccount[] = new CurrentAccount[1000];
		byte i = 1,j = 1;
		do
		{
			do
			{
				System.out.println("Start filling values. Enter account type");
				if((input.readLine())=="Savings")
				{
		                            	SavingsAccount sAccount[i];
					sAccount[i] = new SavingsAccount();
					sAccount[i].input();
					i++;
					for(int k=1;k<20;k++)
						System.out.println();
				}
				else if((input.readLine())=="Current")
				{
					CurrentAccount cAccount[j]=new CurrentAccount();		
					cAccount[j].input();
					j++;
					for(int k=1;k<20;k++)
						System.out.println();
				}
				else
					System.out.println("Invalid Entry");
			}while((input.readLine())!="Savings"||(input.readLine())!="Current");
			System.out.println("Do you want to enter more account information?Y/N");
			if((input.readLine())=="Y")
				ans=true;
		}while(ans==true);			
	}
}

In the above code, I seem to get six errors, three ']' expected and the three ';' expected. One of the lines is line 102... please check and tell me an amendment?

Recommended Answers

All 15 Replies

Use code tags. The button is right there on your reply box. It says 'code'. That way we will know what line you are talking about.

import java.io.*;
import java.lang.*;
import java.util.*;


class CustomerInfo
{
public String name = new String();
public String accnNumber =new Sting();
public String accnType = new String();
public float balance = 0.0F;
public float rateOfInterest =0.0F;
public float interest = 0.0F;
public float useBalance = 0.0F;
public String password = new String();

void input()
throws IOException
{
System.out.println("Please Enter information");
System.out.print("Enter Name :");
DataInputStream input = new DataInputStream(System.in);
name = input.readLine();
System.out.println();
System.out.print("Enter Account Number : ");
accnNumber = input.readLine();
System.out.println();
System.out.print("Enter Balance: Rs.");
balance = Float.parseFloat(input.readLine());
System.out.println();
System.out.print("Assign a password that you can remember");
password = input.readLine();
System.out.println();
}
}


class Transactions extends CustomerInfo
{
float wthdrw = 0.0F;
float dpst = 0.0F;

void withdraw()
throws IOException
{
DataInputStream input = new DataInputStream(System.in);
System.out.println("You current opening balance is Rs." + useBalance);
System.out.print("Enter the amount to withdraw : Rs.");
wthdrw = Float.parseFloat(input.readLine());
System.out.println();
useBalance-= wthdrw;
System.out.println("The closing balance after withdrawal is Rs." + useBalance);
}
void deposit()
throws IOException
{
DataInputStream input = new DataInputStream(System.in);
System.out.print("Enter the amount to deposit : Rs.");
dpst=Float.parseFloat(input.readLine());
useBalance+= dpst;
System.out.println();
System.out.println("The closing balance after this deposit is Rs."+ useBalance);
}
void calcInterest(float useBalance,float rateOfInterest, boolean ans)
throws IOException
{
interest = (useBalance*rateOfIntrest)/100;
System.out.print("Interest per month is Rs"+interest);
System.out.print("Do you want to see the current usable balance when added to yearly income?Y/N");
if((input.read())=='Y')
ans = true;
if(ans==true)
System.out.println("The amount after one annum will become Rs."+(useBalance+(12*interest)));
else
System.out.println("Thank you");
}
}


class SavingsAccount extends Transaction
{
public SavingsAccount()
{
final float minBalance = 5000;
useBalance = balance-minBalance;
accnType = "Savings";
rateOfInterest1 = 10;
}

void actions()
throws IOException
{
DataInputStream input = new DataInputStream(System.in);

SavingsAccount sAccount[]=new SavingsAccount[1000];
do
{
System.out.println("What do want to do?");
System.out.println("1.Withdraw");
System.out.println("2.Deposit");
i=1;
SavingsAccount sAccount[i]=new SavingsAccount();
if((input.read())=='1')
sAccount[i].withdraw();
else if((input.read())=='2')
sAccount[i].deposit();
}while((input.read())!='1'||(input.read())!='2');
System.out.println("Do you want to see the interest?Y/N");
if((input.read())=='Y')
sAccount[i].calcInterest(useBalance,rateOfInterest,true);
else
System.out.println("Thank you.");

}
}

class CurrentAccount extends Transaction
{
public CurrentAccount()
{
final float minBalance2 = 3000;
useBalance = balance-minBalance2;
accnType = "Current";
rateOfInterest2 = 2;
}

void actions()
throws IOException
{
DataInputStream input = new DataInputStream(System.in);
do
{
System.out.println("What do want to do?");
System.out.println("1.Withdraw");
System.out.println("2.Deposit");
if((input.readLine())==1)
cAccount[j].withdraw();
else if((input.readLine())==2)
cAccount[j].deposit();
}while((input.read())!='1'||(input.read())!='2');
System.out.println("Do you want to see the interest?Y/N");
if((input.read())=='Y')
cAccount[j].calcInterest(useBalance,rateOfInterest2,true);
else
System.out.println("Thank you.");

}
}

class BankHQ
{
public static void main(String args[])
throws IOException
{
SavingsAccount sAccount[] = new SavingsAccount[1000];
CurrentAccount cAccount[] = new CurrentAccount[1000];
byte i = 1,j = 1;
do
{
do
{
System.out.println("Start filling values. Enter account type");
if((input.readLine())=="Savings")
{
SavingsAccount sAccount[i];
sAccount[i] = new SavingsAccount();
sAccount[i].input();
i++;
for(int k=1;k<20;k++)
System.out.println();
}
else if((input.readLine())=="Current")
{
CurrentAccount cAccount[j]=new CurrentAccount();
cAccount[j].input();
j++;
for(int k=1;k<20;k++)
System.out.println();
}
else
System.out.println("Invalid Entry");
}while((input.readLine())!="Savings"||(input.readLine())!="Current");
System.out.println("Do you want to enter more account information?Y/N");
if((input.readLine())=="Y")
ans=true;
}while(ans==true);
}
}

It says expected ']' and ';' errors at three places of which one is line 102. Please check and explain to me the mistake?
Thank You.

SavingsAccount sAccount[i]=new SavingsAccount();

Should be

sAccount[i]=new SavingsAccount();

As for the other errors I don't know because you didn't mention the line numbers. You should just paste the entire error message here.

Also if possible try to indent your code. It makes it much easier to read if each block of code is indented by 4 spaces (unless BBcode has a tab tag).

Also if possible try to indent your code. It makes it much easier to read if each block of code is indented by 4 spaces (unless BBcode has a tab tag).

Actually, my code is totally indented, when I pasted it here, it re-formatted.

import java.io.*;
import java.lang.*;
import java.util.*;


class CustomerInfo
{
	public String name = new String();
	public String accnNumber =new Sting();
	public String accnType = new String();
	public float balance = 0.0F;
	public float rateOfInterest =0.0F;
	public float interest = 0.0F;
	public float useBalance = 0.0F;
	public String password = new String();

	void input()
	throws IOException
	{
		System.out.println("Please Enter information");
		System.out.print("Enter Name :");
		DataInputStream input = new DataInputStream(System.in);
		name = input.readLine();
		System.out.println();
		System.out.print("Enter Account Number : ");
		accnNumber = input.readLine();
		System.out.println();
		System.out.print("Enter Balance: Rs.");
		balance = Float.parseFloat(input.readLine());
		System.out.println();
		System.out.print("Assign a password that you can remember");
		password = input.readLine();
		System.out.println();
	}
}


class Transactions extends CustomerInfo
{
	float wthdrw = 0.0F;
	float dpst = 0.0F;
	
	void withdraw()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		System.out.println("You current opening balance is Rs." + useBalance);
		System.out.print("Enter the amount to withdraw : Rs.");
		wthdrw = Float.parseFloat(input.readLine());
		System.out.println();
		useBalance-= wthdrw;
		System.out.println("The closing balance after withdrawal is Rs." + useBalance);
	}
	void deposit()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		System.out.print("Enter the amount to deposit : Rs.");
		dpst=Float.parseFloat(input.readLine());
		useBalance+= dpst;
		System.out.println();
		System.out.println("The closing balance after this deposit is Rs."+ useBalance);
	}
	void calcInterest(float useBalance,float rateOfInterest, boolean ans)
	throws IOException
	{
		interest = (useBalance*rateOfIntrest)/100;
		System.out.print("Interest per month is Rs"+interest);	
		System.out.print("Do you want to see the current usable balance when added to yearly income?Y/N");
		if((input.read())=='Y')
			 ans = true;
		if(ans==true)
			System.out.println("The amount after one annum will become Rs."+(useBalance+(12*interest)));
		else
			System.out.println("Thank you");
	}
}


class SavingsAccount extends Transaction
{
	public SavingsAccount()
	{
		final float minBalance = 5000;
		useBalance = balance-minBalance;
		accnType = "Savings";
		rateOfInterest1 = 10;
	}
	
	void actions()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		
		SavingsAccount sAccount[]=new SavingsAccount[1000];
                          do
		{
			System.out.println("What do want to do?");
			System.out.println("1.Withdraw");
			System.out.println("2.Deposit");
			i=1;
                            	sAccount[i] =new SavingsAccount () ;
			if((input.read())=='1')
				sAccount[i].withdraw();
			else if((input.read())=='2')	
				sAccount[i].deposit();
		}while((input.read())!='1'||(input.read())!='2');
		System.out.println("Do you want to see the interest?Y/N");
		if((input.read())=='Y')
			sAccount[i].calcInterest(useBalance,rateOfInterest,true);
		else
			System.out.println("Thank you.");

	}
}

class CurrentAccount extends Transaction
{
	public CurrentAccount()
	{
		final float minBalance2 = 3000;
		useBalance = balance-minBalance2;
		accnType = "Current";
		rateOfInterest2 = 2;
	}

	void actions()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		do
		{
			System.out.println("What do want to do?");
			System.out.println("1.Withdraw");
			System.out.println("2.Deposit");
			if((input.readLine())==1)
				cAccount[j].withdraw();
			else if((input.readLine())==2)	
				cAccount[j].deposit();
		}while((input.read())!='1'||(input.read())!='2');
		System.out.println("Do you want to see the interest?Y/N");
		if((input.read())=='Y')
			cAccount[j].calcInterest(useBalance,rateOfInterest2,true);
		else
			System.out.println("Thank you.");

	}
}

class BankHQ
{
	public static void main(String args[])
	throws IOException
	{
		SavingsAccount sAccount[] = new SavingsAccount[1000];
		CurrentAccount cAccount[] = new CurrentAccount[1000];
		byte i = 1,j = 1;
		do
		{
			do
			{
				System.out.println("Start filling values. Enter account type");
				if((input.readLine())=="Savings")
				{
		                            	SavingsAccount sAccount [i]=new SavingsAccount () ;

					sAccount[i].input();
					i++;
					for(int k=1;k<20;k++)
						System.out.println();
				}
				else if((input.readLine())=="Current")
				{
					cAccount[j]=new CurrentAccount();		
					cAccount[j].input();
					j++;
					for(int k=1;k<20;k++)
						System.out.println();
				}
				else
					System.out.println("Invalid Entry");
			}while((input.readLine())!="Savings"||(input.readLine())!="Current");
			System.out.println("Do you want to enter more account information?Y/N");
			if((input.readLine())=="Y")
				ans=true;
		}while(ans==true);			
	}
}

Here, the indented code, the same error on line 165;
If I design this program right, I'll move to GUI, networking and more programming constraints, I will require and adore any help that I can find here from You guys. Thank You.

ahh... that indenting makes it so much easier to read ^^ thank you.

Ok, so on line 155, you declare the entire array sAccount to hold SavingsAccount values. Once that has been declared, you don't need to define the individual elements as SavingsAccount values -- the compiler already knows this. Thus, on line 165, where you say SavingsAccount sAccount [i]=new SavingsAccount () ; you are in a sense being "redundant." We already know that sAccount will be a SavingsAccount -- every element in the sAccount array will be! So you can write sAccount [i]=new SavingsAccount () ; to fix your error here.

I knew of it,
But after I make the change You suggested, it gives me 41 errors which I don't know how to report for I use cmd for compiling.

Regards,
Gary.

ok dude it has a lot of syntax error . .
just use an IDE to figure out what is the error of your code. Because it's so hard to figure out when you compiled it in the cmd

ok dude it has a lot of syntax error . .
just use an IDE to figure out what is the error of your code. Because it's so hard to figure out when you compiled it in the cmd

It doesn't make any difference whether it is compiled using a IDE or a command prompt.
They do the same thing:
> The IDE will point in the code where the error is. So does the command prompt. The error message specifies the file and line where the error happened
> The IDE has a short message of the error. So does the command prompt. It has a mesage as what went wrong and sometimes it says what is needed fixing.

Now if you or the poster are too lazy to read the error messages at the command prompt because you like better the pretty colors of an IDE that is something else.


So my suggestion is:
DifficultUsrnme If you get error messages, the READ them. They explain the error and show the line. Of course if some errors are too difficult of course post them, but I doubt that all 41 errors are impossible.
If they are, try to copy paste them here. Right click on the command prompt to open a small dialog box that will help you copy them

And if fixing something causes more errors, you are doing yourself good. By putting the error back in your program on purpose, you might get rid of the other error messages, but you are actually further from solving your problem. Error messages are good, and many times, it will say 41 errors, you'll fix 1-3 things, and you'll have no errors anymore.

And if fixing something causes more errors, you are doing yourself good. By putting the error back in your program on purpose, you might get rid of the other error messages, but you are actually further from solving your problem. Error messages are good, and many times, it will say 41 errors, you'll fix 1-3 things, and you'll have no errors anymore.

True, the same thing happened. I re-read the entire code and made changes, it's working now, but now I need some more help. I don't know the protocols to this forum well, so do tell me, I want to continue adding functionality to the code, if I need help on the new part, am I to mark this thread solved and start a new one or keep on asking in this one only.

True, the same thing happened. I re-read the entire code and made changes, it's working now, but now I need some more help. I don't know the protocols to this forum well, so do tell me, I want to continue adding functionality to the code, if I need help on the new part, am I to mark this thread solved and start a new one or keep on asking in this one only.

By the way, somehow, now that I've got it working, when You enter Savings/ Current as an account type. Well, I mean it only says Invalid Entry.
So, please do tell me what is the problem please?

import java.io.*;
import java.lang.*;
import java.util.*;


class CustomerInfo
{
	public String name = new String();
	public String accnNumber =new String();
	public String accnType = new String();
	public float balance = 0.0F;
	public float rateOfInterest =0.0F;
	public float interest = 0.0F;
	public float useBalance = 0.0F;
	public String password = new String();

	void input()
	throws IOException
	{
		System.out.println("Please Enter information");
		System.out.print("Enter Name :");
		DataInputStream input = new DataInputStream(System.in);
		name = input.readLine();
		System.out.println();
		System.out.print("Enter Account Number : ");
		accnNumber = input.readLine();
		System.out.println();
		System.out.print("Enter Balance: Rs.");
		balance = Float.parseFloat(input.readLine());
		System.out.println();
		System.out.print("Assign a password that you can remember   ") ;
		password = input.readLine();
		System.out.println();
	}
}


class Transactions extends CustomerInfo
{
	float wthdrw = 0.0F;
	float dpst = 0.0F;
	
	void withdraw()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		System.out.println("You current opening balance is Rs." + useBalance);
		System.out.print("Enter the amount to withdraw : Rs.");
		wthdrw = Float.parseFloat(input.readLine());
		System.out.println();
		useBalance-= wthdrw;
		System.out.println("The closing balance after withdrawal is Rs." + useBalance);
	}
	void deposit()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		System.out.print("Enter the amount to deposit : Rs.");
		dpst=Float.parseFloat(input.readLine());
		useBalance+= dpst;
		System.out.println();
		System.out.println("The closing balance after this deposit is Rs."+ useBalance);
	}
	void calcInterest(float useBalance,float rateOfInterest, boolean ans)
	throws IOException
	{
                DataInputStream input = new DataInputStream(System.in);
		interest = (useBalance*rateOfInterest)/100;
		System.out.print("Interest per month is Rs"+interest);	
		System.out.print("Do you want to see the current usable balance when added to yearly income?Y/N");
		if((input.read())=='Y')
			 ans = true;
		if(ans==true)
			System.out.println("The amount after one annum will become Rs."+(useBalance+(12*interest)));
		else
			System.out.println("Thank you");
	}
}


class SavingsAccount extends Transactions
{
	public SavingsAccount()
	{
		final float minBalance = 5000;
		useBalance = balance-minBalance;
		accnType = "Savings";
		rateOfInterest = 10;
	}
	
	void actions(SavingsAccount[] sAccount)
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		
	             byte i;
                          do
		{
			System.out.println("What do want to do?");
			System.out.println("1.Withdraw");
			System.out.println("2.Deposit");
			i=1;
                            	sAccount[i] =new SavingsAccount();
			if((input.read())=='1')
				sAccount[i].withdraw();
			else if((input.read())=='2')	
				sAccount[i].deposit();
		}while((input.read())!='1'||(input.read())!='2');
		System.out.println("Do you want to see the interest?Y/N");
		if((input.read())=='Y')
			sAccount[i].calcInterest(useBalance,rateOfInterest,true);
		else
			System.out.println("Thank you.");

	}
}

class CurrentAccount extends Transactions
{
	public CurrentAccount()
	{
		final float minBalance2 = 3000;
		useBalance = balance-minBalance2;
		accnType = "Current";
		int rateOfInterest = 2;
	}

	void actions(CurrentAccount[] cAccount)
	throws IOException
	{
		byte j=1;
		DataInputStream input = new DataInputStream(System.in);
		do
		{
			System.out.println("What do want to do?");
			System.out.println("1.Withdraw");
			System.out.println("2.Deposit");
			if((input.read())=='1')
				cAccount[j].withdraw();
			else if((input.read())=='2')	
				cAccount[j].deposit();
		}while((input.read())!='1'||(input.read())!='2');
		System.out.println("Do you want to see the interest?Y/N");
		if((input.read())=='Y')
			cAccount[j].calcInterest(useBalance,rateOfInterest,true);
		else
			System.out.println("Thank you.");

	}
}

class BankHQ
{
	public static void main(String args[])
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in) ;
		boolean ans;		
		SavingsAccount sAccount[] = new SavingsAccount[1000];
		CurrentAccount cAccount[] = new CurrentAccount[1000];
		
		byte i = 1,j = 1;
		do
		{
				ans= false; 	
			
				System.out.print("Start filling values. Enter account type : ");
				if(input.readLine().equals("Savings"))
				{
		                            	sAccount [i]=new SavingsAccount() ;

					sAccount[i].input();
					i++;
					for(int k=1;k<100;k++)
						System.out.println();
				}
				else 
				if(input.readLine().equals("Current"))
				{
					cAccount[j]=new CurrentAccount();		
					cAccount[j].input();
					j++;
					for(int k=1;k<100;k++)
						System.out.println();
				}
				else
					System.out.println("Invalid Entry");

			System.out.println("Do you want to enter more account information?Y/N");
			if(input.read()=='Y'||input.read()=='y')
			{
				ans=true;
			}
		}while(ans==true);			
	}
}

True, the same thing happened. I re-read the entire code and made changes, it's working now, but now I need some more help. I don't know the protocols to this forum well, so do tell me, I want to continue adding functionality to the code, if I need help on the new part, am I to mark this thread solved and start a new one or keep on asking in this one only.

By the way, somehow, now that I've got it working, when You enter Savings/ Current as an account type. Well, I mean it only says Invalid Entry.
So, please do tell me what is the problem please?

import java.io.*;
import java.lang.*;
import java.util.*;


class CustomerInfo
{
	public String name = new String();
	public String accnNumber =new String();
	public String accnType = new String();
	public float balance = 0.0F;
	public float rateOfInterest =0.0F;
	public float interest = 0.0F;
	public float useBalance = 0.0F;
	public String password = new String();

	void input()
	throws IOException
	{
		System.out.println("Please Enter information");
		System.out.print("Enter Name :");
		DataInputStream input = new DataInputStream(System.in);
		name = input.readLine();
		System.out.println();
		System.out.print("Enter Account Number : ");
		accnNumber = input.readLine();
		System.out.println();
		System.out.print("Enter Balance: Rs.");
		balance = Float.parseFloat(input.readLine());
		System.out.println();
		System.out.print("Assign a password that you can remember   ") ;
		password = input.readLine();
		System.out.println();
	}
}


class Transactions extends CustomerInfo
{
	float wthdrw = 0.0F;
	float dpst = 0.0F;
	
	void withdraw()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		System.out.println("You current opening balance is Rs." + useBalance);
		System.out.print("Enter the amount to withdraw : Rs.");
		wthdrw = Float.parseFloat(input.readLine());
		System.out.println();
		useBalance-= wthdrw;
		System.out.println("The closing balance after withdrawal is Rs." + useBalance);
	}
	void deposit()
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		System.out.print("Enter the amount to deposit : Rs.");
		dpst=Float.parseFloat(input.readLine());
		useBalance+= dpst;
		System.out.println();
		System.out.println("The closing balance after this deposit is Rs."+ useBalance);
	}
	void calcInterest(float useBalance,float rateOfInterest, boolean ans)
	throws IOException
	{
                DataInputStream input = new DataInputStream(System.in);
		interest = (useBalance*rateOfInterest)/100;
		System.out.print("Interest per month is Rs"+interest);	
		System.out.print("Do you want to see the current usable balance when added to yearly income?Y/N");
		if((input.read())=='Y')
			 ans = true;
		if(ans==true)
			System.out.println("The amount after one annum will become Rs."+(useBalance+(12*interest)));
		else
			System.out.println("Thank you");
	}
}


class SavingsAccount extends Transactions
{
	public SavingsAccount()
	{
		final float minBalance = 5000;
		useBalance = balance-minBalance;
		accnType = "Savings";
		rateOfInterest = 10;
	}
	
	void actions(SavingsAccount[] sAccount)
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in);
		
	             byte i;
                          do
		{
			System.out.println("What do want to do?");
			System.out.println("1.Withdraw");
			System.out.println("2.Deposit");
			i=1;
                            	sAccount[i] =new SavingsAccount();
			if((input.read())=='1')
				sAccount[i].withdraw();
			else if((input.read())=='2')	
				sAccount[i].deposit();
		}while((input.read())!='1'||(input.read())!='2');
		System.out.println("Do you want to see the interest?Y/N");
		if((input.read())=='Y')
			sAccount[i].calcInterest(useBalance,rateOfInterest,true);
		else
			System.out.println("Thank you.");

	}
}

class CurrentAccount extends Transactions
{
	public CurrentAccount()
	{
		final float minBalance2 = 3000;
		useBalance = balance-minBalance2;
		accnType = "Current";
		int rateOfInterest = 2;
	}

	void actions(CurrentAccount[] cAccount)
	throws IOException
	{
		byte j=1;
		DataInputStream input = new DataInputStream(System.in);
		do
		{
			System.out.println("What do want to do?");
			System.out.println("1.Withdraw");
			System.out.println("2.Deposit");
			if((input.read())=='1')
				cAccount[j].withdraw();
			else if((input.read())=='2')	
				cAccount[j].deposit();
		}while((input.read())!='1'||(input.read())!='2');
		System.out.println("Do you want to see the interest?Y/N");
		if((input.read())=='Y')
			cAccount[j].calcInterest(useBalance,rateOfInterest,true);
		else
			System.out.println("Thank you.");

	}
}

class BankHQ
{
	public static void main(String args[])
	throws IOException
	{
		DataInputStream input = new DataInputStream(System.in) ;
		boolean ans;		
		SavingsAccount sAccount[] = new SavingsAccount[1000];
		CurrentAccount cAccount[] = new CurrentAccount[1000];
		
		byte i = 1,j = 1;
		do
		{
				ans= false; 	
			
				System.out.print("Start filling values. Enter account type : ");
				if(input.readLine().equals("Savings"))
				{
		                            	sAccount [i]=new SavingsAccount() ;

					sAccount[i].input();
					i++;
					for(int k=1;k<100;k++)
						System.out.println();
				}
				else 
				if(input.readLine().equals("Current"))
				{
					cAccount[j]=new CurrentAccount();		
					cAccount[j].input();
					j++;
					for(int k=1;k<100;k++)
						System.out.println();
				}
				else
					System.out.println("Invalid Entry");

			System.out.println("Do you want to enter more account information?Y/N");
			if(input.read()=='Y'||input.read()=='y')
			{
				ans=true;
			}
		}while(ans==true);			
	}
}

True, the same thing happened. I re-read the entire code and made changes, it's working now, but now I need some more help. I don't know the protocols to this forum well, so do tell me, I want to continue adding functionality to the code, if I need help on the new part, am I to mark this thread solved and start a new one or keep on asking in this one only.

That's really up to you, but I'd recommend to mark solved and start a new thread. Most people won't read through a thread this long to figure out what's going on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.