Ok, I'm new to java and I need a little help with this if statement. Or possibly a different approach on how to write it.

The if statement first needs to determine what type of package the user has so they may be charged a base fee. (Package A, B or C)

Next the user will have an additional charge if they went over their hours based on their package.

For package A, if they went over 10 hours they are charged $2 per hour they went over.
For package B, if they went over 20 hours they are charged $1 per hour they went over.
For package C, the user has unlimited hours.

Here is how I attempted to write it, but Java says:

InternetCharges.java:75: illegal start of expression
if (packageType == 'A')&&(hours > 10)
1 error

So I am assuming the And symbol will not work with two variables.

	if (packageType == 'A')&&(hours > 10)
	        fees = PACKAGE_A + (hours-10) * 2;
	else if (packageType == 'A')&&(hours <= 10)
	        fees = PACKAGE_A;
	else if (packageType == 'B')&&(hours > 20)
		fees = PACKAGE_B + (hours-20) * 1;
	else if (packageType == 'B')&&(hours <= 20)
		fees = PACKAGE_B;
	else fees = PACKAGE_C;
return fees;

The condition of the if statement is enclosed in parans. If you have more than one condition they ALL must be within the one enclosing pair of parans.

Yeah I just realized that, just didn't know how to delete the post, thanks for the reply though

This article has been dead for over six months. Start a new discussion instead.