r/programminghelp • • Jan 14 '22

Answered What's wrong with my simple java code?

import java.util.*;
public class test {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		System.out.print("Enter your name :");
		String st = s.nextLine();
		System.out.print("Enter your age :");
		int age = s.nextInt();
		System.out.print("Enter your year of birth :");
		String y = s.nextLine();
		System.out.print("Enter your father name :");
		String fn = s.nextLine();
		System.out.print("Name :" + st);
		System.out.print("Age :" + age);
		System.out.print("Year of birth :" + y);
		System.out.print("Your father is " + fn);
	}
}

Whenever it reaches "enter your year of birth", it jumps the instruction.

Please help. I'm gonna be crazy.

5 Upvotes

2 comments sorted by