Can someone look at my program. I am having a problem with my Scanner line. Does anyone know how to fix this problem??
I keep getting an error at this part:
letter = scan.nextLine();
import java.util.Scanner;
public class ATMdriver
{
public static void main(String[] args)
{
ATM atm=new ATM();
char letter;
int timePass;
do
{
System.out.println();
System.out.println("What would you like to do ?");
System.out.println("W - Withdraw money from the ATM");
System.out.println("T - Add twenties to the ATM");
System.out.println("F - Add fives to the ATM");
System.out.println("Q - Quit");
System.out.println("");
Scanner scan = new Scanner (System.in);
letter = scan.nextLine();
System.out.println("");
switch(letter)
{
case 'W':
case 'w':
atm.withdraw();
System.out.println(atm);
break;
case 'T':
case 't':
atm.addTwenties();
System.out.println(atm);
break;
case 'F':
case 'f':
atm.addFives();
System.out.println(atm);
break;
case 'Q':
case 'q':
System.out.println(atm);
break;
default:
System.out.println("Not a valid command. Please reenter.");
break;
}
}while((letter!='q')&&(letter!='Q'));
}
}
Code tags added. -Narue