Results 1 to 4 of 4
- 02-14-2013, 09:46 PM #1
Member
- Join Date
- Feb 2013
- Posts
- 1
- Rep Power
- 0
-
Re: "else" without "if" error .. help
Please edit your post above and add code tags:
Please the tag [code] above your posted code block and the tag [code] below your code block like so:
[code]
[/code]Java Code:// your code goes here public class Foo { }
This way we'll be better able to see your code formatting which should show us if the offending else has a matching if on the right level just before it.
- 02-15-2013, 05:03 AM #3
Re: "else" without "if" error .. help
Here's the removed content:
everything works except at the "else if" statement. I get an error:
Bankaccount.java:34: error: 'else' without 'if'
else if (button.equals("withDrawal"))
^
1 error
import javax.swing.JOptionPane;
public class Bankaccount {
public static void main(String [] args)
{
int balance;
int newBalance;
int deposit = 0;
int withDrawal = 0;
int transferMoney;
String button;
balance = Integer.parseInt(JOptionPane.showInputDialog("Ente r Bank Account Balance"));
if (balance < 0)
{
JOptionPane.showMessageDialog(null, "You must contact bank's customer service department");
}
else
{
button = JOptionPane.showInputDialog("Enter button: Create Deposit, Make Withdrawal, or Transfer Money");
if (button.equals("deposit"))
{
deposit = Integer.parseInt(JOptionPane.showInputDialog(null, "Deposit Amount"));
}
newBalance = balance + deposit;
{
JOptionPane.showMessageDialog(null, "New Balance" +" "+ newBalance);
}
}
else if (button.equals("withDrawal"))
{
withDrawal = Double.parseDouble(JOptionPane.showInputDialog(nul l, "Withrawal Amount"));
}
}
}
THREAD CLOSEDWhy do they call it rush hour when nothing moves? - Robin Williams
-
Re: "else" without "if" error .. help
Next time, rather than delete your question, please post your solution here so that you can help folks with similar problems in the future.
Similar Threads
-
java.lang.NullpointerException error in tomcat 5.5 / http status 500 error
By rahil in forum Apache CommonsReplies: 3Last Post: 05-08-2012, 05:26 PM -
> Operator cannot be applied error and return incompatible types error
By corney_16 in forum New To JavaReplies: 1Last Post: 03-10-2010, 01:53 PM -
Thread: Error 500--Internal Server Error java.lang.NullPointerException
By jackdear44 in forum New To JavaReplies: 1Last Post: 12-05-2009, 07:28 AM -
java.lang.Error: Error opening DSound for capture
By NARs in forum NetworkingReplies: 1Last Post: 10-26-2009, 04:38 PM


LinkBack URL
About LinkBacks

Bookmarks