Help with Homework plz!

This is a discussion on Help with Homework plz! within the C++ Programming forums, part of the General Programming Boards category; Hi new to the forums, thought you guys might be able to help me out, maybe not. I have a ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    1

    Help with Homework plz!

    Hi new to the forums, thought you guys might be able to help me out, maybe not. I have a programming assignment as it follows:

    1. Star Search (10 points) A particular talent competition is taking place on campus. This competition has 5 judges, each of whom awards a score between 0 and 10 to each contestant. Fractional scores, such as 7.4, are allowed. A contestant’s final score is determined by dropping the highest and lowest score received, then averaging the 3 remaining score. Allow the user to enter scores for as many contestants as wanted until the user indicates otherwise (do loop).

    Write a C++ program called StarSearch that does the following. Note that I have given you the function header/signature for all of the functions you will be writing for this assignment. You may want to refer the example we did in class. Examples are posted on BlackBoard.

    □ display the contestant number. This integer variable is incremented for each contestant.

    □ implements a function
    void getJudgeData(double &score)
    that asks the user for a judge’s score, stores it in a reference parameter variable, and validates it. Input Validation: Do not accept judge scores lower than 0 or higher than 10. This function should be called by main once for each of the 5 judges. Hint: review Using Reference Variables as Parameters in your textbook in chapter 6 .

    □ implements a function
    void calcScore(double s1, double s2, double s3, double s4, double s5)
    that calculates and displays the average of the 3 scores that remain after dropping the highest and lowest score the contestant received. It will call functions findLowest and findHighest to determine the lowest and highest scores. The function calcScore is called just once by main, and should be passed the 5 scores. The average score should be displayed to 2 decimal places.

    □ implements a function
    double findLowest(double s1, double s2, double s3, double s4, double s5)
    that finds and returns the lowest of the 5 scores passed to it. This function is called by calcScore to determine which score to drop as the lowest.

    □ implements a function
    double findHighest (double s1, double s2, double s3, double s4, double s5)
    that finds and returns the highest of the 5 scores passed to it. This function is called by calcScore to determine which score to drop as the highest.


    I really am not sure what my if statement should look like when trying to knock off the highest and lowest score given...then to average the 3 remaining scores. any help at all would be awesome thanks!

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Code:
    if (var < max && var > min)
    {valid} else {invalid}

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,803
    One way to do it: Add all five numbers together then subtract whatever findHighest and findLowest return. That will give you the sum of the remaining three values, no if test required. You then only need to divide by three to get the average.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Try it first.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,671
    Since it escaped your attention on your way in.
    http://cboard.cprogramming.com/annou...t.php?f=3&a=39

    Attention on our part is dependent on effort on your part.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can any1 plz make this assignment
    By jean in forum C Programming
    Replies: 17
    Last Post: 05-13-2009, 09:19 PM
  2. Need help with homework assignment plz..
    By RVDFan85 in forum C++ Programming
    Replies: 13
    Last Post: 10-05-2006, 10:33 PM
  3. homework help about ofstream/ifstream.. help PLZ
    By kv2 in forum C++ Programming
    Replies: 1
    Last Post: 12-13-2001, 12:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21