Appreciate any help with my problem.

I'm quite new to c++ I'm experimenting a little with the CMD console, I'm really not experienced so the structure of my program is terrible, I'm freely open to more efficient ways, so feel free to tell me what I could do to improve it.


I'm trying to modify the program so that it will notify the user of their letter grade: 0-59=F 60-69=D 70-79=C 80-89=B 90-100=A

How would I go about doing this, if I input a score between 0-59 it'll print "you've achieved an F"




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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <string>

using namespace std;

void z() {Sleep(50);}

char x[] = "This is a simple program, which will enable to input your score and recieve the correct grade, depending on what score you input.\n ";



int main()

{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);
for(int i = 0; i < 135; i++)



{
cout << x[i];
z();
}

Sleep(2000);
cout << "                                                                           To continue, press ENTER" << endl; cin.get();
system ("CLS");
Sleep(300);

string mystr;


int scoreA=100;
int scoreB=59;
int scoreC=69;
int scoreD=79;
int scoreE=89;
int score2;


cout << "hello, what is your NAME? " << endl;
getline(cin,mystr);
cout << "Loading grades......\n\n\n" << endl; Sleep(3000);
cout << "input your score, " << mystr << endl;
cin >> score2;













{
 if (scoreA==score2)

cout << "You've achieved an A+" << endl;
}

{
 if (scoreB==score2)

cout << "You've achieved an F-" << endl;
}

{
 if (scoreE==score2)

cout << "You've achieved a B-" << endl;
}

{
 if (scoreD==score2)

cout << "You've achieved a C-" << endl;
}

return 0;



}
1
2
3
4
if (Score >= 0 && Score <= 59)
{
// Your code.
}
try this
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
#include <iostream>
#include <conio.h>

using namespace std;
string mystr;

int main(){

	float num;
	cout<<"enter your name:";
	getline(cin,mystr);
	cout<<"enter your score "<<mystr<<":";
	cin>>num;

	if(num>0 && num<=59)
	{
		cout<<"you've achieved F";
	}
	else if(num>=60 && num<=69)
	{
		cout<<"you've achieved D";
	}
	else if(num>=70 && num<=79)
	{
		cout<<"you've achieved C";
	}
	else if(num>=80 && num<=89)
		{
			cout<<"you've achieved B";
		}
	else if(num>=90 && num<=100)
	{
		cout<<"you've achieved A";
	}

}
Thanks a lot, to both of you.

Topic archived. No new replies allowed.