4 Replies - 110 Views - Last Post: 12 September 2012 - 08:11 PM Rate Topic: -----

#1 ITreallyhappens  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-September 12

I have a problem regarding in how to connect scores in a string

Posted 12 September 2012 - 07:46 AM

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?

Is This A Good Question/Topic? 0
  • +

Replies To: I have a problem regarding in how to connect scores in a string

#2 Cuzzie  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 72
  • View blog
  • Posts: 341
  • Joined: 16-July 10

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.
Was This Post Helpful? 1
  • +
  • -

#3 WannaJava?  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 27
  • Joined: 11-September 12

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.
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 9036
  • View blog
  • Posts: 33,508
  • Joined: 27-December 08

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.
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8022
  • View blog
  • Posts: 31,133
  • Joined: 06-March 08

Re: I have a problem regarding in how to connect scores in a string

Posted 12 September 2012 - 08:11 PM

View PostITreallyhappens, 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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1