Results 1 to 11 of 11
  1. #1
    siick is offline Member
    Join Date
    Aug 2010
    Posts
    3
    Rep Power
    0

    Default New java student, question about algorithm, please help :)

    Hey everyone!
    So i just got out of my first java programming class, and i've got my first homework assignment.

    I just want to know if my logic is heading in the right direction, maybe get some tips, any help would be greatly appreciated.
    heres my problem.
    i need to write an algorithm for a program that can do the following
    names and testscores need to be entered
    calculate average test score
    determine and print names of all students who are below average
    determine high score
    print names of students who are = to high score


    so far ive worked out that i need to
    ask user to input name, and testscore-input name -input testscore
    i need to store name and testscore-?
    i need to create a total variable to store a running average-
    testaverage=testaverage +testscore x total
    i need to ask for a new name, and if yes, i need to input the name and new score.
    i need to compare that score with whats stored in "testscore" variable
    then i need to out 2 lists
    below average
    and
    high score[s]

    I am sooo confused on where to start, or how to loop to create new variables... basically im just confused. any help would be great appreciated!!!!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,259
    Rep Power
    25

    Default

    I assume that this program is to work with the console.
    Start with a simple program that writes/prints a message, reads in the response and prints it. No more. When that is working, we'll move to the next step.
    Use the Scanner class to read in the input. Search on this forum for code samples that use Scanner.

  3. #3
    siick is offline Member
    Join Date
    Aug 2010
    Posts
    3
    Rep Power
    0

    Default

    hi, ok i dont think i explained myself properly, my bad.

    i dont need to actually CODE that program. ive only had 1 class, i need to demonstrate that i could explain to someone how i would make that program work more or less.
    after attempting it a bit more ive come up with this


    *************
    input name
    input score
    count=1
    highS=name

    ask if user has more names and scores to enter

    If yes then
    count=count +1
    input morename
    input morescore
    total=score+morescore
    TA=TA+total/count
    if morescore=>TA then belowA=morename
    if morescore=<TA then highS=morename
    output belowA (" is below average")
    output highS ("is at or tied with the highest score" )
    Else
    output highS

    ***************

    obv as you can see that is not code at all, but thats what my teacher is looking for, a diagram written out explaining the algorithm for that problem.
    it needs to be as simplistic as possible.
    hopefully im making sense.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,259
    Rep Power
    25

    Default

    Yes that makes sense.
    What specific questions do you have?

  5. #5
    gafa's Avatar
    gafa is offline Senior Member
    Join Date
    Jun 2010
    Posts
    107
    Rep Power
    0

    Default

    try to start a code and when you face a problem let us know I guess

  6. #6
    siick is offline Member
    Join Date
    Aug 2010
    Posts
    3
    Rep Power
    0

    Default

    MY TASK
    i need to write an algorithm for a program that can do the following
    names and testscores need to be entered
    calculate average test score
    determine and print names of all students
    who are below average
    determine high score
    print names of students who are = to high score




    ok soooo basically i dont need to write ANY ACTUAL CODE.
    i need to explain in plain english what an algorithm for this program would consist of.

    what i wrote was wrong by my professors standards and i cant reach him to ask him anything else.
    if someone could critique my estimation and tell me if im leaving something out that would be good.
    -----------------------
    I need the user to input names and scores
    those names and scores have to be linked together
    two lists need to be created that allow for multiple name and score variables( a below average list and a high score list)
    the computer needs to keep a running total of all scores entered
    the computer needs to create a running average of those scores
    it needs to ask the user if they have more scores to enter
    if the answer is yes
    then the above process should be looped as many times as needed.
    if the answer is no
    the computer needs compare all scores with the average
    for all scores that are lower than the average they get put into the below average list
    next the computer needs to find the highest score and place the name of that person into the highscore list.
    now it should compare every score with the highest score, if anything is equal to it, their name will also be placed on the highscore list.

    now the computer should output both lists to the user
    the names of the below average students
    and the names of the students with the highest score
    -----------------------------------------------------

    would that be the ENTIRE plan for building this program? keep in mind im only asking for help to ensure i have ALL the steps necessary to write the program. i don't need any actual code.

    thank you again for your time guys i appreciate it!
    my homework is due tomorrow night and im trying to figure this all out.





    EDIT:
    i already noticed holes in my logic after i wrote those steps, to show you what i mean ill explain it, when i wrote
    "the computer needs to keep a running total of all scores entered
    the computer needs to create a running average of those scores"
    i should have written
    " the computer needs to keep a running total by adding all scores together while they are entered
    the computer also needs to create a running average by adding the current average with total and dividing by the number of entries"

    so i need to explain my logic really concisely

    thanks again!
    Last edited by siick; 08-24-2010 at 05:30 AM.

  7. #7
    colpwd is offline Member
    Join Date
    Aug 2010
    Posts
    25
    Rep Power
    0

    Default

    You might want to look at pseudocode and how its formally written if you have not already.

    This will give your explanation of how something should be coded some backbone.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    a running average by adding the current average with total and dividing by the number of entries
    No, that's not correct.

    db

  9. #9
    gafa's Avatar
    gafa is offline Senior Member
    Join Date
    Jun 2010
    Posts
    107
    Rep Power
    0

    Default

    Quote Originally Posted by siick View Post
    MY TASK
    i need to write an algorithm for a program that can do the following
    names and testscores need to be entered
    calculate average test score
    determine and print names of all students
    who are below average
    determine high score
    print names of students who are = to high score




    ok soooo basically i dont need to write ANY ACTUAL CODE.
    i need to explain in plain english what an algorithm for this program would consist of.

    what i wrote was wrong by my professors standards and i cant reach him to ask him anything else.
    if someone could critique my estimation and tell me if im leaving something out that would be good.
    -----------------------
    I need the user to input names and scores
    those names and scores have to be linked together
    two lists need to be created that allow for multiple name and score variables( a below average list and a high score list)
    the computer needs to keep a running total of all scores entered
    the computer needs to create a running average of those scores
    it needs to ask the user if they have more scores to enter
    if the answer is yes
    then the above process should be looped as many times as needed.
    if the answer is no
    the computer needs compare all scores with the average
    for all scores that are lower than the average they get put into the below average list
    next the computer needs to find the highest score and place the name of that person into the highscore list.
    now it should compare every score with the highest score, if anything is equal to it, their name will also be placed on the highscore list.

    now the computer should output both lists to the user
    the names of the below average students
    and the names of the students with the highest score
    -----------------------------------------------------

    would that be the ENTIRE plan for building this program? keep in mind im only asking for help to ensure i have ALL the steps necessary to write the program. i don't need any actual code.

    thank you again for your time guys i appreciate it!
    my homework is due tomorrow night and im trying to figure this all out.





    EDIT:
    i already noticed holes in my logic after i wrote those steps, to show you what i mean ill explain it, when i wrote
    "the computer needs to keep a running total of all scores entered
    the computer needs to create a running average of those scores"
    i should have written
    " the computer needs to keep a running total by adding all scores together while they are entered
    the computer also needs to create a running average by adding the current average with total and dividing by the number of entries"

    so i need to explain my logic really concisely

    thanks again!
    put your attention for pseudocode manner then I guess

  10. #10
    gafa's Avatar
    gafa is offline Senior Member
    Join Date
    Jun 2010
    Posts
    107
    Rep Power
    0

    Default

    the computer needs to keep a running total of all scores entered
    But you can write it like this instead of a novel book manner I think

    loop BEGIN
    length=scores sum
    iterator=scores element desc
    loop END
    Last edited by gafa; 08-25-2010 at 04:45 AM.

  11. #11
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    im sorry but this takes nothing more than basic math and a piece of paper

Similar Threads

  1. A new student study Java
    By MSs.Java in forum New To Java
    Replies: 11
    Last Post: 06-20-2014, 08:31 AM
  2. Replies: 2
    Last Post: 03-09-2010, 09:42 AM
  3. Netbeans java bsased student project
    By jagadish_321 in forum NetBeans
    Replies: 1
    Last Post: 02-04-2009, 04:28 AM
  4. New java student needs help
    By cmizer in forum New To Java
    Replies: 9
    Last Post: 12-13-2008, 06:16 AM
  5. Help with algorithm in java
    By coco in forum AWT / Swing
    Replies: 1
    Last Post: 08-01-2007, 06:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •