0 Replies - 217 Views - Last Post: 18 July 2014 - 12:18 PM Rate Topic: -----

#1 seanjames192  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 21-January 14

Stuck on creating and using functions

Posted 18 July 2014 - 12:18 PM

Hello i am just doing a basic grading program that i would like modified to have a menuchoice to select one test score or multiple scores. From there it asks for the test score or scores, then calls for the average function to get the final score average from the inputted values. Then uses that final score to decide the final grade. i wanted to use an array to allow the user to enter as many test scores as they want without having to declare individual var or ints. i would like to take care of the errors first and then figure out a more simple logic for it. I feel i have overdone such a simple thing.

<code>

#include <iostream>

using namespace std;

void menuChoice(int, int);
void scoreAverage(int);
void singleTest(int);
void tests(int);

int main()

{
int choice, choice2, finalScore;


cout << " Would you like to enter 1 test score or multiple test scores? " << endl;
cout << " 1. Single Test Score /n 2. Multiple Test Scores " << endl;
cin >> choice;
menuChoice(choice, choice2);
scoreAverage(finalScore);


return 0;
}

/* create function to allow choice for 1 test score or multiple / or look up how to enter multiple scores without needing
pre define score1 score2 and so on <<< MAYBE LOOK UP ARRAYS ???>>>> */

menuChoice(choice, choice2)
{
int choice;

singleTest(score);
if (choice = 1)
else if (choice = 2)
tests();
else
cout << " please enter 1 or 2 for your selection " << endl;


return();
}
/* function to allow a single test score */
singleTest(score)
{
int score;
cout << " Please enter 1 test score " << endl;
cin >> score;


return(score);
}
/* function to allow for multiple test scores */
tests(int)
{
int scores[];
cout << " Please Enter as many test scores as you would like " << endl;
cin >> scores[];


return();
}
/* create function to get average of test scores and assign to final score */

scoreAverage()
{
int finalScore;

if (finalScore > 90 )
cout << " Congratulations! you got an A! " << endl;
else if (finalScore < 90 )
cout << " Congratulations! you got a B! " << endl;
else if (finalScore <= 79 )
cout << " You passed! you got a C! " << endl;
else if (finalScore < 70 )
cout << " Whoops! you got a D! " << endl;
else (finalScore < 65 );
cout << " You failed. You received an F " << endl;


return(finalScore);
}



</code>

Is This A Good Question/Topic? 0
  • +

Page 1 of 1