Forums Register Login

Java error

+Pie Number of slices to send: Send
I am trying to compile a java application and am getting an errror:


TestAccount.java:1: error: <identifier> expected
import.java.util.Scanner;
^
1 error

How do I fix this?


Original code:



Code:


import.java.util.Scanner;


public class TestAccount {
public static void main (String[] args) {
Scanner kb = new Scanner (System.in);

System.out.print("Enter the number for account #1: ");
int accountNo = kb.nextInt();

System.out.print("Enter the balance for account #1: ");
double balance = kb.nextDouble();

CheckingAccount account1 = new CheckingAccount(accountNo, balance);

System.out.print("Enter the number for account #2: ");
int accountNo = kb.nextInt();

System.out.print("Enter the balance for account #2: ");
double balance = kb.nextDouble();

CheckingAccount account2 = new CheckingAccount(accountNo, balance);

System.out.println("---ACCOUNT #1---");
System.out.println(account1);

System.out.println("---ACCOUNT #2---");
System.out.println(account2);
}
}



Thanks for any help.
+Pie Number of slices to send: Send
Hello keith michael, welcome to the JavaRanch.

Could you edit your post and wrap your code with the code tags? It will help us to understand your code.

Is that your class code? is there any other line above the import?
+Pie Number of slices to send: Send
Carefully look at the import statement. Some unwanted character lurking around there
+Pie Number of slices to send: Send
The keyword import ought to be followed by a space, not a dot.

And welcome (again) I shall see about adding code tags for you since you are new, and you can see how much better the code looks.
+Pie Number of slices to send: Send
Code tags wouldn’t work because you haven’t indented the code you posted.
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 785 times.
Similar Threads
Having troubles with a complex program, need help with an illegal start of type error.
the most bizarre java error ever
Stumped, need inspiration.
The most bizarre java error ever
Bank program class or switch problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:22:14.