r/programminghomework • • Oct 02 '12

Question about Java variables

Here is the question

Write a Java application that plays a word game with the user. The program asks the user to enter the following: Two names, a city, a university, a profession, an animal, two numbers.

Basically I don't understand how to allow the user to input a word, or words, for the variable.

I believe I have to use,

Char name1, blah, blah;

Scanner keyboard = new Scanner(System.in);

System.out.print("Type a name");

name1 = keyboard.nextChar();

however its not working so does the variable need to be something else or is it a problem elsewhere?

1 Upvotes

2 comments sorted by

View all comments

Show parent comment

1

u/MasterOfEspeonage Jan 10 '13

Yea this is kinda old, I couldn't understand how to read what the user input for a string.