Hello! I've been learning C++ for about 3 days now, and I was wondering if you guys had any tips on condensing this, or if you had any criticism on the way I code.
cout << "\nYou got a " << (Percent * 100) << "%";
if (Percent < 0.60) {
cout << "\nHow'd you get an F man...\n\n";
}
elseif (Percent < 0.70) {
cout << "\nWow... a D... I mean at least you didn't get an F...\n\n";
}
elseif (Percent < 0.80) {
cout << "\nNice C, but you probably could've done better...\n\n";
}
elseif (Percent < 0.90) {
cout << "\nI mean a B isn't bad, but you should strive for better...\n\n";
}
elseif (Percent < 1.00) {
cout << "\nOoooh you are a true JungKookster!! Keep being a happy BTS fan!\n\n";
}
else {
cout << "!!!!!!!!\nYou are worthy of being the president of the Army Fanbase!\n\n";
}
return 0;
An addition to whats been said, a few more things:
There is a condensed way of writing this: Score = Score + Point;
And that is: Score += Point;
Line 48 is incorrect: if (Answer == "Busan" || "busan")
It should be: if (Answer == "Busan" || Answer == "busan")
You might also want to start getting used to doing without the usingnamespace std; and instead use the scope resolution operator like std::cout<< instead of cout <<
All in all, good code. Wish you best in learning further :)
It's not. It is just a hot-button issue with C++ pedants.
Whenever you usingnamespaceanything; you are dumping every symbol in 'anything's namespace into the current namespace. This may cause unexpected collisions.
In large, production-level code, there is rarely any reason to do that.
In most other cases (anything you are creating right now) it really isn't an issue.