• Post Reply Bookmark Topic Watch Topic
  • New Topic

Add Method Question  RSS feed

 
Frances Hollis
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what to put in the body of this method. Code is provided that asks for the user to input the student name, number and gpa. I can't find any examples that don't have the input hard coded. Yes, this is homework, I just don't understand the syntax to use. The logic I get (I think).

Thanks, Frances

:confuse
 
Luciano Mantuaneli
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what syntax exactly you don't understand?
 
Frances Hollis
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What goes in the body of the method. How do I tell the method that the student the user inputs is to be added?

Frances.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Firstly you need to remove the ; from public boolean add(Student s);

You need to use the System.in variable to obtain inputs from a console. More specifically, you need to use a Reader to read data from System.in

Once you read this data you can put it into a Student class using its setter methods and then use the add(Student student) function to add this student to your student Set (ie your myRoster variable).

Use the following code fragment to read data from the console.



That fragment will return a String. That fragment translates to , "read whatever the user has typed" and it will read data after the user presses the enter key.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!