Results 1 to 4 of 4
- 01-20-2013, 06:11 PM #1
Member
- Join Date
- Jan 2013
- Posts
- 1
- Rep Power
- 0
Help! i keep getting error: class, interface, or enum expected
public class BankAccount
{
private int balance;
public BankAccount()
{
balance = 10000;
}
public int withdraw(int amount)
{
balance-=amount;
return amount;
}
public int getBalance()
{
return balance;
}
}
import java.util.Scanner;
class BankAccountTester
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
BankAccount myAccount = new BankAccount();
System.out.println("Balance = " + myAccount.getBalance());
System.out.print("Enter amount to be withdrawn: ");
int amount = scan.nextInt();
assert (amount >= 0 && amount <= myAccount.getBalance()):"You can't withdraw that amount!";
myAccount.withdraw(amount);
System.out.println("Balance = " + myAccount.getBalance());
}
}
this i my code, the problem is with the import java.util.scanner
it gives me the error: class, interface, or enum expected , bnut i dont know how to fix it.
- 01-20-2013, 06:52 PM #2
Member
- Join Date
- Dec 2012
- Location
- Des Moines, IA
- Posts
- 33
- Rep Power
- 0
Re: Help! i keep getting error: class, interface, or enum expected
Try reformatting you code with the code tags and show us the error your getting. That would help us out.
- 01-20-2013, 07:45 PM #3
Re: Help! i keep getting error: class, interface, or enum expected
Hello and welcome! Please use [code][/code] tags when posting code so we can easily read it!
Forum Rules
Guide For New Members
BB Code List - Java Programming Forum
Shouldn't it beJava Code:java.util.scanner
?Java Code:java.util.Scanner;
- 01-20-2013, 08:06 PM #4
Similar Threads
-
class, interface, or enum expected
By CrazyTofu999 in forum New To JavaReplies: 4Last Post: 01-12-2013, 08:31 PM -
Getting error, "class, interface or enum expected", not sure why.
By DesertFlower in forum New To JavaReplies: 4Last Post: 12-08-2012, 10:56 AM -
having problem with a class, interface, or enum expected error msg plss help
By victorious in forum New To JavaReplies: 1Last Post: 10-03-2012, 09:38 PM -
class interface or enum expected Imports java.io.*; error
By prathamkool in forum New To JavaReplies: 2Last Post: 10-02-2011, 04:53 PM -
keep getting error message class, interface, or enum expected
By darr in forum New To JavaReplies: 2Last Post: 10-02-2010, 02:13 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks