Make running java program that inputs the camper's name and
user enters a score in each of four areas. Scores range from 1 to 10. The four areas are: swimming,tennis,horsemanship and crafts.
The output is the total score that is the sum of the entered name's skill scores. Design an interactive screen for this program.
input name: Mark
enter score for swimming: 2
enter score for tennis: 4
enter score for horsemanship: 6
enter score for crafts: 1
Mark's total score: 13
loop until user finished entering data.
will i use GUI in this program?
how can i connect the string name to the scores then get its total sum?
any advice or programs that can help would do..
thanks
by the way.. i will use try and catch in order to hold the maximum value not exceeding the score of 10?
4 Replies - 110 Views - Last Post: 12 September 2012 - 08:11 PM
#1
I have a problem regarding in how to connect scores in a string
Posted 12 September 2012 - 07:46 AM
Replies To: I have a problem regarding in how to connect scores in a string
#2
Re: I have a problem regarding in how to connect scores in a string
Posted 12 September 2012 - 08:03 AM
Quote
will i use GUI in this program?
That's up to you, but I don't think that's necessary. You can just make a console application that uses Scanner to take in user input, and normal System.out.println() to show the output.
Quote
how can i connect the string name to the scores then get its total sum?
Huh? Why do you need to connect the name to the scores? You can have 5 different variables for this: name, swimmingScore, tennisScore, horsemanshipScore, and craftsScore, then print out the value of these variables, and calculate the total sum.
Quote
by the way.. i will use try and catch in order to hold the maximum value not exceeding the score of 10?
You can use a do-while loop to keep looping the user if he enters a value that exceeds 10.
#3
Re: I have a problem regarding in how to connect scores in a string
Posted 12 September 2012 - 08:42 AM
You don't need to link the string name to the scores, you can simple create a camper class to create a camper object. You then store the values there using a constructor. Like Cuzzie said, you don't need to 'link' them together.
Also, I would recommend doing a console menu for this project if you are new to GUI.
You don't have to use a try and catch, though it is good practice. You can check input with and if statement or a while loop.
Also, I would recommend doing a console menu for this project if you are new to GUI.
You don't have to use a try and catch, though it is good practice. You can check input with and if statement or a while loop.
#4
Re: I have a problem regarding in how to connect scores in a string
Posted 12 September 2012 - 08:46 AM
Check out my tutorial Moving Away From Parallel Arrays for a good starting point.
#5
Re: I have a problem regarding in how to connect scores in a string
Posted 12 September 2012 - 08:11 PM
ITreallyhappens, on 12 September 2012 - 10:46 AM, said:
by the way.. i will use try and catch in order to hold the maximum value not exceeding the score of 10?
No this is not a good practice...
try/catch clauses are for unpredicable error trapping
If you can can p[redict the event and thus throw the Exception you shouldn't do it
a if() statement would do the job
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote







|