the error is at the curly brace under void main() line 28 can some one help me...pleasee

#include <iomanip>
#include <curses.h>
#include <stdlib.h>
#include <fstream>
#include <iomanip>
#include <cmath>

using namespace std;

//nonvoid function
int main()
{

}
    float Final_pt(float GP_work,float GP_exam,int Eval)
{
    float Grade_n, Grade;
    if(Eval==1)
       Grade_n = GP_work*0.3 + GP_exam*0.7;
    else
        Grade_n = GP_work*0.4 + GP_exam*0.6;
        Grade = Grade_n;
    return Grade;

void main ()
{

    int matric_no, courses_no, units,evaluation, sum= 0 , fail=0;
    float gradept_coursework, gradept_exam,final_pt, average=0.0, gradeptfnl;
    char response='y';
    char* grade;
    cout << setw(47) << "UNIVERSITI SAINS MALAYSIA" << endl;
    cout << setw(60) << "STUDENTS' RESULTS SEMESTER 2 ACADEMIC YEAR 2019/2020" << endl << endl;

    while (response =='y')
    {
    int i=1;
    cout << "Matric Number: ";
    cin >> matric_no ;
    cout << "\nEnter the number of courses taken: ";
    cin >> courses_no;
    cout << "Enter the units, grade points for coursework and exam, and evaluation code (1 for 30/70, or 2 for 40/60): " << endl << endl;
        do  {
            cin >> units >> gradept_coursework >> gradept_exam >> evaluation;
            final_pt = Final_pt(gradept_coursework, gradept_exam, evaluation);
                if (final_pt >= 3.84)

                    grade = "A";
                else if (final_pt >= 3.5)
                    grade = "A-";
                else if (final_pt >= 3.17)
                    grade = "B+";
                else if (final_pt >= 2.84)
                    grade = "B";
                else if (final_pt >= 2.50)
                    grade = "B-";
                else if (final_pt >= 2.17)
                    grade = "C+";
                else if (final_pt >= 1.84)
                    grade = "C";
                else if (final_pt >= 1.50)
                    grade = "C-";
                else if (final_pt >= 1.17)
                    grade = "D+";
                else if (final_pt >= 0.84)
                    grade = "D";
                else if (final_pt >= 0.34)
                    grade = "D-";
                else
                    grade = "F";

            cout << "Final grade of the course " << i << " : " << grade << endl << endl;
            ++i;

            if (grade == "A")
                gradeptfnl = 4.00;
            else if (grade == "A-")
            gradeptfnl = 3.67;
            else if (grade == "B+")
            gradeptfnl = 3.33;
            else if (grade == "B")
            gradeptfnl = 3.00;
            else if (grade == "B-")
            gradeptfnl = 2.67;
            else if (grade == "C+")
            gradeptfnl = 2.33;
            else if (grade == "C")
            gradeptfnl = 2.00;
            else if (grade == "C-")
            gradeptfnl = 1.67;
            else if (grade == "D+")
            gradeptfnl = 1.33;
            else if (grade == "D")
            gradeptfnl = 1.00;
            else if (grade == "D-")
            gradeptfnl = 0.67;
            else if (grade == "F")
            gradeptfnl = 0.00;

            sum = sum + units;
            average= average + gradeptfnl*units;

            if (final_pt < 2.0)
                fail = fail+1 ;

        } while (i <= courses_no);
            average = average/sum ;

                cout << "Number of units is: " << sum << endl << endl;

                cout << "Grade point average = " << average << endl;

                if (average >= 2.00)
                    cout << "Status : Active" << endl ;
                else
                    cout << "Status: Not Active" << endl ;

                if (fail == 0)
                    cout << "Do not need to repeat any course" << endl ;
                else if ( fail != 0)
                    cout << "Need to repeat " << fail << " course" << endl ;

                if ( average >= 3.50 && sum >= 12)
                    cout << "Eligible for Dean's list." << endl ;
                else
                    cout << "Not eligible for Dean's list. " << endl ;

    cout << "\nDo you want to process for another student? Type 'y' is yes, 'n' if no : ";
    cin >> response;
    }
    _getch();
    return 0;

}
}

int main()
{
    int studentcount, students, score;
    float totalscores, average, leastscore=100, highscore=0;
    string studentname;

    cout<<"How many students have taken the exam"<<endl;
    cin>> students;

    totalscores=0.0;
    studentcount=0;

    while(students>studentcount)
    {
        cout<<"what is the student name: "<<endl;
        cin>>studentname;
        cout<<"Please enter scores: ";
        cin>> score;
        cout<<studentname<< " got a score of "<<score<<endl;

        if(score>=0&&score<=100)
        {
        if (score<leastscore)
            {
                leastscore=score;
            }

        else if(score>highscore)
            {
                highscore=score;
            }
        }

        if(score<100 && score>89)
            {
                cout<<studentname<<"'s letter grade is an A."<<endl;;
            }
        else if(score<90 && score>79)
            {
                cout<<studentname<<"'s letter grade is a B."<<endl;
            }
        else if(score<80 && score>69)
            {
                cout<<studentname<< "'s letter grade is a C."<<endl;
            }
        else
            {
                cout<<studentname<<" failed."<<endl;
            }

        studentcount=studentcount+1;
        totalscores=totalscores+score;
    }

    average=totalscores/students;

    cout<<"The class average was :"<<average<<endl;
    cout<<"The highscore was :"<<highscore<<endl;
    cout<<"The low score was: "<<leastscore<<endl;

    system("pause");
    return 0;
}

Recommended Answers

All 3 Replies

I have not looked at a line of C++ code in 20+ years, but I don't remember if you can declare multiple variables on a single line and define some of them and not others as you are doing.

I see a few issues.

  1. What's up with lines 11 and 26? Two mains?
  2. I won't count them again but the { and } seem unbalanced as well. Correct item 1 then check your braces.

I see three mains, actually.

commented: Thanks. I stopped reading after the second then {}'s looked unbalanced. Not much needed to fix if that's it. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.