0

Apologies in advance I only started learning to code very recently, with no experience in the field. My code looks like this

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int accNo, choice = 4;
    String accName;
    String accType;
    double balance;
    System.out.print("Enter Account No :");
    accNo = input.nextInt();

    System.out.print("Name : ");
    accName = input.nextLine();
    
    System.out.print("Account Type : ");
    accType = input.nextLine();
    
    System.out.print("Opening Balance : ");
    balance = input.nextDouble();

But it prints off like this with name and account type being the same thing

Enter Account No :1231234

Name : Account Type :

Any ideas?

Jack
  • 1
  • 1
  • 2
    Does this answer your question? [Scanner is skipping nextLine() after using next() or nextFoo()?](https://stackoverflow.com/questions/13102045/scanner-is-skipping-nextline-after-using-next-or-nextfoo) – maloomeister Oct 14 '21 at 09:01
  • Yes! thanks buddy – Jack Oct 14 '21 at 09:04

0 Answers0