0
//

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


int main()
{
    float assign1, assign2, assign3, assign4, examScore;

    float assignWeight;

    cout << " Welcome to UOW Score System" << endl;
    cout << " " << endl;

    cout << "Enter the scores for Assignment 1 / 2 / 3 / 4" << endl;
    cout << "==> " << endl;
    cin >> assign1 >> assign2 >> assign3 >> assign4;

    cin.clear ();
    cin.ignore (100, '\n');

    cout << "Enter the weight for each assignment" << endl;
    cout << "==> " << endl;

    cin >> assignWeight;

    cin.clear ();
    cin.ignore (100, '\n');

    cout << "Enter the score for exam" << endl;
    cout << "== > " << endl;

    cin >> examScore;

    cin.clear ();
    cin.ignore (100, '\n');

    cout << " " << endl;

    cout << "Summary for eliminations" << endl;

    cout << setw (24) << setfill ('=') << "=" << endl;
    cout << setfill (' ');

    char assiPoll;

    char minimumID, minimumID2;

    //Eliminating first score.
    if ((assign1 <= assign2) && (assign1 <= assign3) && (assign1 <= assign4))

    {
        cout << "Assignment 1 first score has been eliminated." << endl;

        assiPoll = 1, minimumID = 1;

    }

        else if ((assign2 <= assign1) && (assign2 <= assign3) && (assign2 <= assign4))

        {

            cout << "Assignment 2 first score has been eliminated." << endl;

            assiPoll = 2, minimumID = 2;
        }

        else if ((assign3 <= assign1) && (assign3 <= assign2) && (assign3 <= assign4))
        {
            cout << "Assignment 3 first score has been eliminated." << endl;

            assiPoll = 3, minimumID = 3;

        }
        else if ((assign4 <= assign1) && (assign4 <= assign2) && (assign4 <= assign3))
        {
            cout << "Assignment 4 first score has been eliminated." << endl;

            assiPoll = 4, minimumID = 4;

        }

    //Eliminating the second score.
    switch (assiPoll)
    {
    case 1:

            if ((assign2 <= assign3) && (assign2 <= assign4))
            cout << "Assignment 2 second score has been eliminated." << (minimumID2 = 2)
            << endl;

        else if ((assign3 <= assign2) && (assign3 <= assign4))
            cout << "Assignment 3 second score has been eliminated." << (minimumID2 = 3)
            << endl;

        else if ((assign4 <= assign2) && (assign4 <= assign3))
            cout << "Assignment 4 second score has been eliminated." << (minimumID2 = 4)
            << endl;

    break;

        case 2:

            if ((assign1 <= assign3) && (assign1 <= assign4))
            cout << "Assignment 1 second score has been eliminated." << (minimumID2 = 1)
            << endl;
        else if ((assign3 <= assign1) && (assign3 <= assign4))
            cout << "Assignment 3 second score has been eliminated." << (minimumID2 = 3)
            << endl;
        else if ((assign4 <= assign1) && (assign4 <= assign3))
            cout << "Assignment 4 second score has been eliminated." << (minimumID2 = 4)
            << endl;
            break;

        case 3:

            if ((assign1 <= assign2) && (assign1 <= assign4))
            cout << "Assignment 1 second score has been eliminated." << (minimumID2 = 1)
            << endl;
        else if ((assign2 <= assign1) && (assign2 <= assign4))
            cout << "Assignment 2 second score has been eliminated." << (minimumID2 = 2)
            << endl;
        else if ((assign4 <= assign1) && (assign4 <= assign2)) 
            cout << "Assignment 4 second score has been eliminated." << (minimumID2 = 4)
            << endl;
            break;

        case 4:

            if ((assign1 <= assign2) && (assign1 <= assign3))
            cout << "Assignment 1 second score has been eliminated." << (minimumID2 = 1)
             << endl;
        else if ((assign2 <= assign1) && (assign2 <= assign3))
            cout << "Assignment 2 second score has been eliminated." << (minimumID2 = 2)
            << endl;
        else if ((assign3 <= assign1) && (assign3 <= assign2))
            cout << "Assignment 3 second score has been eliminated." << (minimumID2 = 3)
            << endl;
            break;
    }

    //Summary Result
    cout << " " << endl;
    cout << "Summary Results" << endl;
    cout << setw (15) << setfill ('=') << "=" << endl;
    cout << setfill (' ');
    cout << " " << endl;

    cout << left << setw(13) << "Assignment"
    << left << setw (8) << "Result"
    << left << setw (5) << "Remark"
    << endl;
    cout << " " << endl;

    if (minimumID == 1)
    {
        cout << left << setw(13) << "Assignment 1"
        << left << setw (8) << assign1
        << left << setw (5) << "MIN 1 (X)"
        << endl;

    }
    else
    {    
        switch (minimumID2)
        {
            case 1:
                cout << left << setw(13) << "Assignment 1"
                << left << setw (8) << assign1
                << left << setw (5) << "MIN 2 (X)"
                << endl;
                break;
            default:

                cout << left << setw(13) << "Assignment 1"
                << left << setw (8) << assign1
                << left << setw (5) << " "
                << endl;
                break;
        }
    }

    if (minimumID == 2)
    {
        cout << left << setw(13) << "Assignment 2"
        << left << setw (8) << assign2
        << left << setw (5) << "MIN 1 (X)"
        << endl;

    }
    else
    {
        switch (minimumID2)
        {
            case 2:
                cout << left << setw(13) << "Assignment 2"
                << left << setw (8) << assign2
                << left << setw (5) << "MIN 2 (X)"
                << endl;
                break;
            default:

                cout << left << setw(13) << "Assignment 2"
                << left << setw (8) << assign2
                << left << setw (5) << " "
                << endl;
                break;
        }

        if (minimumID == 3)
        {
            cout << left << setw(13) << "Assignment 3"
            << left << setw (8) << assign3
            << left << setw (5) << "MIN 1 (X)"
            << endl;
        }

        else 
        {
            switch (minimumID2)
            {
                case 3:
                    cout << left << setw(13) << "Assignment 3"
                    << left << setw (8) << assign3
                    << left << setw (5) << "MIN 2 (X)"
                    << endl;
                    break;
                default:

                    cout << left << setw(13) << "Assignment 3"
                    << left << setw (8) << assign3
                    << left << setw (5) << " "
                    << endl;
                    break;
            }
        }
        if (minimumID == 4)
        {
            cout << left << setw(13) << "Assignment 4"
            << left << setw (8) << assign4
            << left << setw (5) << "MIN 1 (X)"
            << endl;

        }
        else
        {
                switch (minimumID2)
            {
                case 4:
                    cout << left << setw(13) << "Assignment 4"
                    << left << setw (8) << assign4
                    << left << setw (5) << "MIN 2 (X)"
                    << endl;
                    break;
                default:

                    cout << left << setw(13) << "Assignment 4"
                    << left << setw (8) << assign4
                    << left << setw (5) << " "
                    << endl;
                    break;
            }
        }
    }

    return 0;

}

I'm stuck at the point where I'm supposed to enter scores and the program will eliminate the two lowest scores for me.

For instance I enter
1 2 3 4
for assignments 1-4 respectively, the result will come out right.
But if I enter
9 6 7 8
only the first two assignment results will show but not others.

What seems to be wrong here guys?

Thanks.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Gonbe
0

The code in itself is quite poor. In addition it's not clear to me what the program SHOULD do. Can you explain what the input is supposed to represent, when and which scores should be elinated and other relevant information? When entering the values you supplied the application outputs:

Assignment 2 first score has been eliminated.
Assignment 3 second score has been eliminated.

Which I guess is what you don't want. I don't understand the logic of your application though.. If I were you I'd re-write it from scratch and set it up better. A good start would be is to identify subproblems that could be contained in a function.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.