So when I compile it says i'm missing an if statement at line 38/39 but im using nested else if's and when I take it out it causes more errors.

import java.util.*;

public class lhlBanking
{
static final double servicecharge_savings = 10.00;
static final double servicecharge_checking = 25.00;
static final double Interest_SAVINGS = 0.04;
static final double checkingatmost = 0.03;
static final double checkingatleast = 0.05;
static final double MAX_CHECKING = 5000.00;


public static void main(String[] args)
{
String input;
int C_account;
char T_account;
double mimimum_current_balance_allowed;
double current_current_balance;

Scanner sc = new Scanner(System.in);

System.out.println("Input your account number and select account T_account(savings or checking),"+
"what is the required mimimum_current_balance_allowed current_balance, What is the current current_balance.");


if ((current_balance < mimimum_current_balance_allowed)||(T_account == 'S' || T_account == 's'))
			{
			current_balance = current_balance - servicecharge_savings;
			}
else if(T_account == 'C' || T_account == 'c')
	{
	current_balance = current_balance - servicecharge_checking;
	}
else
	{
	return;
	}
else if
	{
		if (T_account == 'S' || T_account == 's')
			{
			current_balance = current_balance + (current_balance * Interest_SAVINGS);
			}
	}
else if(T_account == 'C' || T_account == 'c')
	{
	if (current_balance - mimimum_current_balance_allowed < MAX_CHECKING)
		{
		current_balance = current_balance + (current_balance * checkingatmost);
		}
	}
else if
	{
	current_balance = current_balance + (current_balance * checkingatleast);
	}
else
	{
	return;
	}
}

}

Recommended Answers

All 11 Replies

Check for correctly pairing of { with }

You need to properly format your code so you can see the pairings of the { and }
The line with the ending } should start vertically below the line with the starting {
All lines between them should be indented 3-4 spaces.

the else clause at line 35 is redundant with that at line at 57 .try removing lines 35 to 38.

ok i fixed that problem still probably not lined up but now it saying can't find symbol variable console and it highlights the console part

C_account = console.nextInt();
T_account = console.nextChar();
mimimum_current_balance_allowed = console.nextDouble();
current_balance = console.nextDouble();

Check for correctly pairing of { with }

You need to properly format your code so you can see the pairings of the { and }
The line with the ending } should start vertically below the line with the starting {
All lines between them should be indented 3-4 spaces.

i removed it and this is my new code only thing wrong is some kind of console variable as mentioned in prev. post

import java.util.*;

public class lhlBanking
{

Scanner sc = new Scanner(System.in);

static final double servicecharge_savings = 10.00;
static final double servicecharge_checking = 25.00;
static final double Interest_SAVINGS = 0.04;
static final double checkingatmost = 0.03;
static final double checkingatleast = 0.05;
static final double MAX_CHECKING = 5000.00;


public static void main(String[] args)

{
int C_account;
char T_account;
double mimimum_current_balance_allowed;
double current_balance;


System.out.println("Input your account number and select account (savings or checking),"+
"what is the required mimimum allowed balance, What is the current balance.");

C_account = console.nextInt();
T_account = console.nextChar();
mimimum_current_balance_allowed = console.nextDouble();
current_balance = console.nextDouble();

if ((current_balance < mimimum_current_balance_allowed)||(T_account == 'S' || T_account == 's'))
			{
			current_balance = current_balance - servicecharge_savings;
			}

else if(T_account == 'C' || T_account == 'c')
	{
	current_balance = current_balance - servicecharge_checking;
	}

else if(T_account == 'S' || T_account == 's')
	{
		if (T_account == 'S' || T_account == 's')
			{
			current_balance = current_balance + (current_balance * Interest_SAVINGS);
			}
	}

else if(T_account == 'C' || T_account == 'c')
	{
	if (current_balance - mimimum_current_balance_allowed < MAX_CHECKING)
		{
		current_balance = current_balance + (current_balance * checkingatmost);
		}
	}

else if(T_account == 'C' || T_account == 'c')
	{
	current_balance = current_balance + (current_balance * checkingatleast);
	}

else
	{
	return;
	}

}


}

the else clause at line 35 is redundant with that at line at 57 .try removing lines 35 to 38.

Where is the variable console defined? The compiler can not find a definition for that variable that is in scope where it is being used.

ok everything is fixed but question how can i get it to actually read the char cause it says the console.nextChar(); is invalid??

import java.util.*;


public class lhlBanking
{

static Scanner console = new Scanner(System.in);


static final double servicecharge_savings = 10.00;
static final double servicecharge_checking = 25.00;
static final double Interest_SAVINGS = 0.04;
static final double checkingatmost = 0.03;
static final double checkingatleast = 0.05;
static final double MAX_CHECKING = 5000.00;


public static void main(String[] args)

{

int C_account;
char T_account;
double mimimum_current_balance_allowed;
double current_balance;


System.out.println("Input your account number and select account (savings or checking),"+
"what is the required mimimum allowed balance, What is the current balance.");

C_account = console.nextInt();
T_account = console.nextchar();
mimimum_current_balance_allowed = console.nextDouble();
current_balance = console.nextDouble();

if ((current_balance < mimimum_current_balance_allowed)||(T_account == 'S' || T_account == 's'))
			{
			current_balance = current_balance - servicecharge_savings;
			}

else if(T_account == 'C' || T_account == 'c')
	{
	current_balance = current_balance - servicecharge_checking;
	}

else if(T_account == 'S' || T_account == 's')
	{
		if (T_account == 'S' || T_account == 's')
			{
			current_balance = current_balance + (current_balance * Interest_SAVINGS);
			}
	}

else if(T_account == 'C' || T_account == 'c')
	{
	if (current_balance - mimimum_current_balance_allowed < MAX_CHECKING)
		{
		current_balance = current_balance + (current_balance * checkingatmost);
		}
	}

else if(T_account == 'C' || T_account == 'c')
	{
	current_balance = current_balance + (current_balance * checkingatleast);
	}

else
	{
	return;
	}

}


}

it says the console.nextChar(); is invalid??

Where did you find that method? Did you read the API doc for the Scanner class?
What methods are available that you could use to read data from a user?

in my java book it gives that as away to read in char

Where did you find that method? Did you read the API doc for the Scanner class?
What methods are available that you could use to read data from a user?

The problem is the compiler can't see what is in your book. It goes by what is defined in the API doc.

Perhaps your book is describing a method from another class.

okay, thanks im about to google Api doc thanks for your help and being patient with me!!

The problem is the compiler can't see what is in your book. It goes by what is defined in the API doc.

Perhaps your book is describing a method from another class.

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.