hello, im new to c++ and im having trouble

hello, I'm a beginner to c++ and I'm having a hard time starting it. I don't want it done for me I just want it explained more in detail. the assignment is that a university has asked me to write a program that takes in a students GPA and SAT test scores and with that information they are either waitlisted accepted or denied. a 4.0 GPA being accepted automatically.


Last edited on
So basically the idea is that you are going to have a bunch of if statements. Your first layer will find between which margin their GPA is then depending on their GPA the next layer will look at where their SAT score is and depending on that you can set the result.
ok so I came up with this so far. I'm not sure if this is correct or not.
#include <iostream>

using namespace std;

int main()
{
double GPA, SAT;
cout << "enter GPA: ";
cin >> GPA;

if (GPA >= 4.0)
cout << "accepted" << endl;
if (GPA >= 3.5 && GPA == 3.99);
cout << "enter SAT: ";
cin >> SAT;




return 0;
}

Last edited on
closed account (48T7M4Gy)
if (GPA >= 3.5 && GPA == 3.99) This wouldn't work, can you see why? ( <= 3.99? )

Since you want to solve this yourself, and that is good, I'd suggest you forget about coding for a while and write down some pseudocode particularly expanding on the 'business rules' you have been given.

That way the if statement cascade if, else if ..., else etc will be easier and clearer to you.

- if (GPA >= 4.0) then accepted
- otherwise if GPA between 3.5 and 3.99, and SAT greater than 1400, then admitted
- otherwise ...

etc etc

Also use 'and' 'or' instead of && and || if your compiler allows it. It's clearer.
Last edited on
um i actually dont see why if (GPA >= 3.5 && GPA == 3.99) wouldn't work.
closed account (48T7M4Gy)
There are a couple of ways of looking at it.

If the true business rule test is GPA ranging from 3.5 to 3.99 then you haven't translated it to C++ code.

If one test is GPA == 3.99 as you have written then who cares if there is a subtest GPA >= 3.5?
I'm sorry but I still don't understand. is there any chance you can show me how the first lines are supposed to be so I can just continue it.
closed account (48T7M4Gy)
So you can't translate the table you have been given into pseudocode or even just a simple couple of sentences based on what I have already shown you?

C'mon Mark2396, surely you're not expecting someone here to do your homework for you.
this assignment has me stressed out. I have been working on it for 4 days and I still cant wrap my head around it. but thanks for your previous help/tips. ill take a look at the book again to se if it helps out also.
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>

using namespace std;

int main()
{
    double GPA = 0, SAT = 0;
    
    cout << "enter GPA: ";
    cin >> GPA;
    
    cout << "enter SAT: ";
    cin >> SAT;
    
    if ( GPA >= 4.0 )                        //RULE 1
        cout << "Admit\n";
    else if ( GPA >= 3.5 && GPA <= 3.99 )
        if( SAT >= 1400 )                    //RULE 2
            cout << "Admit\n";
        else if ( SAT >= 1100 && SAT < 1400 )//RULE 3
            cout << "Waitlist\n";
        else                                 //RULE 4
            cout << "Deny\n";
    else if
        //// etc etc
    
    return 0;
}

/*
 ___GPA___-|_____SAT______|_result___
 4.0       | any          |Admit    RULE 1
 3.5-3.99  |above 1400    |Admit    RULE 2
 3.5-3.99  | 1100-1400    |Waitlist RULE 3
 3.5-3.99  |below 1100    |Deny     RULE 4
 3.0-3.49  |above 2000    |Admit
 3.0-3.49  |1500-2000     |Waitlist
 3.0-3.49  |below 1500    |Deny
 Below 3.0 |2300 or above |Admit
 Below 3.0 | below 2300   |Deny
 */
thank you so much Kemort. what made more sense to me of the code you wrote is the separation of each rule. I wasn't looking at it as multiple little puzzles. I was looking at it as one giant problem and a mixture of over thinking made me not understand it. now I do understand it and I managed to finish it and it works perfectly.
closed account (48T7M4Gy)
Glad to help. Always remember breaking a problem down into sizeable pieces more often than not pays off! Cheers :)
Topic archived. No new replies allowed.