aspose file tools*
The moose likes Beginning Java and the fly likes Help with writing a program that gets student information from the user (Lengthy Post) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with writing a program that gets student information from the user (Lengthy Post)" Watch "Help with writing a program that gets student information from the user (Lengthy Post)" New topic
Author

Help with writing a program that gets student information from the user (Lengthy Post)

brent bynum
Greenhorn

Joined: Apr 04, 2012
Posts: 24
I am just going to put the instructions for my assignment then ask my question.

instructions:

Write a program that gets student information from the user and stores it in a file specified by the user.
The program will ask the user to enter the following data for each student in exactly the order listed
below:

ID number
First name
Last name
Letter grades earned in eleven courses

The user will be asked to enter the word “Quit” instead of the next student’s ID number to signal the end
of input.
Do not make any assumptions regarding the number of students. Your program may not ask
the user for the number of students.

Your program must include appropriate input validation:

Valid student ID numbers contain exactly 10 digits.
Valid first names and last names begin with a letter.
Valid letter grades are A+, A, A-, B+, B, B-, C+, C, and F.

The part in BOLD is the first issue with my program I am trying to tackle. I know I am going to need a loop somewhere but I am not sure where to put it. I assume it should go in main that way I can keep going through it until the user enters "QUIT". Is this the right way to go?


Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2851
    
  11

Yes, I think if you go to read an ID number, and instead see the word, "Quit", then you quit the input loop.
Panagiotis Kalogeropoulos
Rancher

Joined: May 27, 2011
Posts: 99

The code is a little bit messy (what is "name" and "phone" variables and why you have named your class gjjjfghjgfhj ??) but I believe that it is just for demonstration. Regarding your question, you must see what your application needs to do. It needs to ask the user for data until the user presses the QUIT button. So the user enters something and you must check whether that something is QUIT or not. If it is QUIT, then close the application, if not then continue parsing the data. This is the main logic of your app. Does that make things more clear for you?
brent bynum
Greenhorn

Joined: Apr 04, 2012
Posts: 24
Panagiotis Kalogeropoulos wrote:The code is a little bit messy (what is "name" and "phone" variables ans why you have named your class gjjjfghjgfhj ??) but I believe that it is just for demonstration. Regarding your question, you must see what your application needs to do. I needs to ask the user for data until the user presses the QUIT button. So the user enters something and you must check whether that something is QUIT or not. If it is QUIT, then close the application, if not then continue parsing the data. This is the main logic of your app. Does that make things more clear for you?


Your correct those little bits are for show. I used them for testing before I coded the other stuff(It won't be in the final program).

Sort of, I am just not sure where to put it since I am using different methods.
Panagiotis Kalogeropoulos
Rancher

Joined: May 27, 2011
Posts: 99

Well there are a few ways to deal with this. The way you have coded your app, the loop must go after you have obtained the filename from the user. Then you could for example check for QUIT in every method (hint: pay attention to error handling, such as the user entering a 9 digit code, an invalid letter grade etc., as mentioned in your specifications). When you read the word QUIT, then update a boolean value accordingly. Then use that boolean in the loop's condition to finish your loop.
brent bynum
Greenhorn

Joined: Apr 04, 2012
Posts: 24
I figured this part out.

Thanks for the help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with writing a program that gets student information from the user (Lengthy Post)