Question

please help me fix the error in here #include<iostream> #include <string> using namespace std; string getStudentName();...

please help me fix the error in here

#include<iostream>
#include <string>
using namespace std;

string getStudentName();
double getNumberExams();
double getScoresAndCalculateTotal(double E);
double calculateAverage(double n, double t);
char determineLetterGrade();
void  displayAverageGrade();

int main()
{
    string StudentName;
    double NumberExam, Average, ScoresAndCalculateTotal;
    char LetterGrade;
    StudentName = getStudentName();
    NumberExam = getNumberExams();
    ScoresAndCalculateTotal= getScoresAndCalculateTotal(NumberExam);
    Average = calculateAverage(NumberExam, ScoresAndCalculateTotal);

    return 0;
}

string getStudentName()
{
    string StudentName;
    cout << "\n\nEnter Student Name:";
    getline(cin, StudentName);

    return StudentName;
}

double getNumberExams()
{
    double NumberExam;
    cout << "\n\n Enter number of Exams :";
    cin >> NumberExam;

    return NumberExam;
}

double getScoresAndCalculateTotal(double E)
{
    int NumberExam;
    double exam;
    double total
do

        {
            for (int counter = 1; counter <= NumberExam; counter = counter + 1)
            {
                do
                {
                    cout << "Enter exam " << counter << " score: ";
                    cin >> exam;
                    total = total + exam;
                }
            }
        }while ()
    double calculateAverage(double n, double t)
    {
        double NumberExam, total, Average;
        return Average = total / NumberExam;
    }
    char determineLetterGrade()
    {
        double Average;
        char determineLetterGrade;
        if (average >= 89.5)
            cout << "You earned an A" << endl << endl;
        else if (average >= 79.5)
            cout << "You earned a B" << endl << endl;
        else if (average >= 69.5)
            cout << "You earned a C" << endl << endl;
        else if (average >= 59.5)
            cout << "You earned a D" << endl << endl;
        else
            cout << "You earned an F" << endl << endl;

        total = 0;



    }
    void  displayAverageGrade()
    {
        cout << "\n\nStudent Name: " << student_name << endl;
        cout << "Total of Exams: " << total << endl << endl << endl;
        cout << "Average: " << average << endl << endl << endl;

    }
}
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new c++ program with name "main.cpp" is created, which contains following code.

main.cpp :

//header files
#include<iostream>
#include <string>
using namespace std;
//function prototypes
string getStudentName();
double getNumberExams();
double getScoresAndCalculateTotal(double);
double calculateAverage(double, double);
char determineLetterGrade(double);
void displayAverageGrade(string,double,double,char);
//main method
int main()
{
//declaring variables
string StudentName;
double NumberExam=0, Average=0, ScoresAndCalculateTotal=0;
char LetterGrade;
//getting student name
StudentName = getStudentName();
//getting number of exams
NumberExam = getNumberExams();
//getting total and calculate sum
ScoresAndCalculateTotal= getScoresAndCalculateTotal(NumberExam);
//calling method to find average
Average = calculateAverage(ScoresAndCalculateTotal,NumberExam);
//calling method to find grade
LetterGrade=determineLetterGrade(Average);
//displaying details
displayAverageGrade(StudentName,ScoresAndCalculateTotal,Average,LetterGrade);
return 0;
}
//method defination
string getStudentName()
{
string StudentName;
//asking to enter student name
cout << "Enter Student Name:";
getline(cin, StudentName);
//return name
return StudentName;
}
//method to get number of exams
double getNumberExams()
{
double NumberExam;
cout << "Enter number of Exams :";
cin >> NumberExam;
//return number of exams
return NumberExam;
}
double getScoresAndCalculateTotal(double NumberExam)
{
double exam=0;
double total=0;
for (int counter = 1; counter <= NumberExam; counter = counter + 1)
{
cout << "Enter exam " << counter << " score: ";
cin >> exam;
total = total + exam;
}
return total;
}
//calculate average
double calculateAverage(double total, double NumberExam)
{
double average=total/NumberExam;
return average;//return average
}
//method to determine grade
char determineLetterGrade(double average)
{
char determineLetterGrade;
if (average >= 89.5)
determineLetterGrade='A';
else if (average >= 79.5 && average < 89.5)
determineLetterGrade='B';
else if (average >= 69.5 && average < 79.5)
determineLetterGrade='C';
else if (average >= 59.5 && average < 69.5)
determineLetterGrade='CD';
else
determineLetterGrade='F';

return determineLetterGrade;//return
}
//display details
void displayAverageGrade(string student_name,double total,double average,char LetterGrade)
{ cout<<"========================================================="<<endl;
cout << "Student Name: " << student_name << endl;
cout << "Total of Exams: " << total << endl;
cout << "Average: " << average << endl;
cout << "Letter Grade: " << LetterGrade<<endl;

}

======================================================

Output : Compile and Run above program and will get the screen as shown below

Screen 1 :Screen asking Student Name , Number of Exams and Exam score

Screen 2 :Screen displaying details

Screen 3 :Screen showing details

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
please help me fix the error in here #include<iostream> #include <string> using namespace std; string getStudentName();...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a psuedocode for this program. #include <iostream> using namespace std; string message; string mappedKey; void...

    Write a psuedocode for this program. #include <iostream> using namespace std; string message; string mappedKey; void messageAndKey(){ string msg; cout << "Enter message: "; getline(cin, msg); cin.ignore(); //message to uppercase for(int i = 0; i < msg.length(); i++){ msg[i] = toupper(msg[i]); } string key; cout << "Enter key: "; getline(cin, key); cin.ignore(); //key to uppercase for(int i = 0; i < key.length(); i++){ key[i] = toupper(key[i]); } //mapping key to message string keyMap = ""; for (int i = 0,j...

  • Can you tell me what is wrong and fix this code. Thanks #include <iostream> #include <string>...

    Can you tell me what is wrong and fix this code. Thanks #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; //function void displaymenu1(); int main ( int argc, char** argv ) { string filename; string character; string enter; int menu1=4; char repeat; // = 'Y' / 'N'; string fname; string fName; string lname; string Lname; string number; string Number; string ch; string Displayall; string line; string search; string found;    string document[1000][6];    ifstream infile; char s[1000];...

  • CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer;...

    CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...

  • can someone help me fix my jeopardy game #include<iostream> #include<stdlib.h> using namespace std; int rollDie() {...

    can someone help me fix my jeopardy game #include<iostream> #include<stdlib.h> using namespace std; int rollDie() { return (rand() % 6+1); } void askYoNs(){ cout<<"Do you want to roll a dice (Y/N)?:"<<endl; } void printScores(int turnTotal,int humanTotal,int compTotal){ int player; int human; if(player==human){ cout<<"Your turn total is "<<turnTotal<<endl; } else{ cout<<"computer turn total is "<<turnTotal<<endl; } cout<<"computer: "<<compTotal<<endl; cout<<"human: "<<humanTotal<<endl; cout<<endl; } int human; int changePlayer(int player){ if(player==human) return 1; return human; } int process(int& turnTotal,int roll,int curr_player,int& humanTotal,int& computerTotal){ if(roll==2...

  • PLEASE HELP WITH THE FIX ME'S #include #include #include #include "CSVparser.hpp" using namespace std; //==...

    PLEASE HELP WITH THE FIX ME'S #include #include #include #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() { amount = 0.0; } }; //============================================================================ // Linked-List class definition //============================================================================ /** * Define a class containing data members and methods to *...

  • #include<iostream> #include<string> #include<iomanip> using namespace std; /* ********* Class Car ************* ********************************* */ class Car {...

    #include<iostream> #include<string> #include<iomanip> using namespace std; /* ********* Class Car ************* ********************************* */ class Car { private: string reportingMark; int carNumber; string kind; bool loaded; string choice; string destination; public: Car() { reportingMark = ""; carNumber = 0; kind = "Others"; loaded = 0; destination = "NONE"; } ~Car() { } void setUpCar(string &reportingMark, int &carNumber, string &kind, bool &loaded, string &destination); }; void input(string &reportingMark, int &carNumber, string &kind, bool &loaded,string choice, string &destination); void output(string &reportingMark, int &carNumber,...

  • Convert to use functions where possible #include<iostream> #include<string> using namespace std; int main() {    string...

    Convert to use functions where possible #include<iostream> #include<string> using namespace std; int main() {    string first, last, job;    double hours, wages, net, gross, tax, taxrate = .40;    double oPay, oHours;    int deductions;    // input section    cout << "Enter First Name: ";    cin >> first;    cout << "Enter Last Name: ";    cin >> last;    cin.ignore();    cout << "Enter Job Title: ";    getline(cin, job);    cout << "Enter Hours Worked:...

  • what is the output for the following code? explain the steps. /*#include <iostream> using namespace std;...

    what is the output for the following code? explain the steps. /*#include <iostream> using namespace std; int f(int &i) { i = 10; return(5 * i); } int main() { int n = 5; f(n); cout << n << "\n"; return 0; } #include <iostream> using namespace std; int sub1(int n) { n--; return n; } int main() { int m = 10; for(int j = 0; j < 10; j++) m -= sub1(j); cout << m << "\n"; return...

  • #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; struct transition{ // transition structure...

    #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; struct transition{ // transition structure char start_state, to_state; char symbol_read; }; void read_DFA(struct transition *t, char *f, int &final_states, int &transitions){ int i, j, count = 0; ifstream dfa_file; string line; stringstream ss; dfa_file.open("dfa.txt"); getline(dfa_file, line); // reading final states for(i = 0; i < line.length(); i++){ if(line[i] >= '0' && line[i] <= '9') f[count++] = line[i]; } final_states = count; // total number of final states // reading...

  • #include <iostream> #include <string> #include "hashT.h" #include "stateData.h" using namespace std; void stateData::setStateInfo(string sName, string sCapital,...

    #include <iostream> #include <string> #include "hashT.h" #include "stateData.h" using namespace std; void stateData::setStateInfo(string sName, string sCapital,    double stArea, int yAdm, int oAdm) {    stateName = sName; stateCapital = sCapital; stArea = stateArea; yAdm = yearOfAdmission; oAdm = orderOfAdmission;       } void stateData::getStateInfo(string& sName, string& sCapital,    double& stArea, int& yAdm, int& oAdm) {    sName = stateName; sCapital = stateCapital; stArea = stateArea; yAdm = yearOfAdmission; oAdm = orderOfAdmission;       } string stateData::getStateName() { return stateName;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT