Suppose that I have to write a program where a mark out of 100 is entered end then the corresponding symbol has to be displayed. A Message indicating whether the person has passed or not, should also be displayed. I must write the program in three steps.
The main function is below. My task is to write a function, namely symbol, of return type char. It receives a mark in a parameter of type int and returns a symbol. The symbol is determined as follows.
mark 0-39: F
mark 40-49: E
mark 50-59: D
mark 60-69: C
mark 70-79: B
mark 80-100:A
Use nested if statements in the function. Test the program with several input values.
#include <iostream>
using namespace std;
// the required function 'symbol' should be inserted here.
int main ( )
{
int mark;
char symb;
cout << "Enter mark out of 100: ";
cin >> mark;
symb = symbol (mark);
cout <<" Symbol corresponding to " << mark << " is " << symb << endl;
return 0;
}
That was the first part of the question.
Question 2
Now i should write another value-returning function, namely passOrNot of return type bool. It receives a symbol in a parameter of type char. If the symbol is either E or F, the value false should be returned (because the person did not pas), otherwise the value true should be returned (because the person passes). Below is the main function again.
#include <iostream>
using namespace std;
// the required functions 'symbol' and 'passOrNot' should be entered here
int main ( )
{
int mark;
char symb;
cout << "Enter the mark out of 100: " ;
cin >> mark;
symb = symbol (mark);
cout << "The symbol corresponding to " << mark << " is " << symb;
if (passOrNot (symb))
cout << ". You pass - congratulations!" << endl;
else
cout << ". Unfortunately you fail." << endl;
return 0;
}
That was the second part of the question
Now the last part of the question.
Write a program that contains the functions 'symbol' and 'passOrNot' that you wrote in the previous two questions. The program has to determine who pass and who do not pass, given a list of marks. The main function should contain a 'while' loop that is repeated until -10 is entered for the mark. Run the program on the list of marks supplied.
33
55
79
49
60
86
-10
I would really appreciate your help guys as i desperately need this. Im having sleepless nights over this, but I got told the people on this site will definately be able to sort me out. My email adress is bdeklerk@hotmail.com if you guys wanna send it there, or otherwise just post solutions here on this site pls.
Ive been trying for the last 4 days, and i dont know where to start. Ive gone through my Problem solving c++ book and many more but no clue as to where to begin. Can you pls help me grey wolf. Im going for classes in c++ soon, but until then i need to figure it out. Ive tried figuring it out, but no joy yet. Is this very hard or quite simple?
#include <iostream>
usingnamespace std;
// the required function 'symbol' should be inserted here.
char symbol(int mark)
{
char returnVal = 'F';
if(mark >= 40)
{
returnVal = 'E';
if(mark >= 50)
{
returnVal = 'D';
if(mark >= 60)
{
returnVal = 'C';
// you should be able to finish this off!
}
}
}
return returnVal;
}
int main ( )
{
int mark;
char symb;
cout << "Enter mark out of 100: ";
cin >> mark;
symb = symbol (mark);
cout <<" Symbol corresponding to " << mark << " is " << symb << endl;
return 0;
}