Odai A.

asked • 01/28/24

Need help with a java coding problem

I am current working on a java problem that goes like this : "Write a program that prompts for and reads a person’s name, age, college name.".

This is my current code:

import java.util.Scanner;

public class Main
{
public static void main(String[] args) {
String college, name;
int age;
Scanner in= new Scanner(System.in);
System.out.println("Enter your name here");
name=in.nextLine();
System.out.println("Enter your age here");
age=in.nextInt();
System.out.println("Enter your college here");
college=in.nextLine();

System.out.println("Hello, my name is " +name+ " and I am " +age+ " years old. I am enjoying my time at " +college+ " very much ");

}
}

The problem is that every time I try to run the code it skips over the college input part so I cant even add a input and it just leaves a space in the output where the college part is supposed to be. If anyone can help me with this I will be very grateful.

2 Answers By Expert Tutors

By:

Petter N. answered • 01/28/24

Tutor
0 (0)

Google Engineer of 12+ Years Specialized in Java & SQL

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.