### if/else problems. Or am I setting this up correctly?

Hi. I am having difficulty understanding exactly how my instructor wants this set up. I have my c++ book, but even with that, it's very difficult incorporating all of what the book wrote, with the different things he wants. So, from reading the instructions and looking at my code, can anyone tell me if I am setting this up ok? Any advice with the if/else statements? Thanks.

 Topics Branches if statement if/else statement Description Write a program that will determine whether the user passed or failed a test. The program will ask the user to input the following: Percent Pass Score This represents the minimum percent scores required to pass the test. Maximum Test Score This represents the maximum total scores in the test. User Test Score This represents the actual scores obtained by the user in the test. From the above input values, the program will compute the user percent scores in the test. It will compare the percent user score with the percent pass score. If the user percent score is equal to or greater than the percent pass score, the program will consider the user having passed the test. Otherwise, the program will consider the user having failed the test. At the end, the program will display the result summary. See the Test section below. Testing Input Test Run 1 (User input is shown in bold) Enter Percent Pass Score: 80 Enter Maximum Test Score: 400 Enter User Test Score: 324 Output Test Run 1 Result Summary Maximum Score = 400 User Test Score = 324 User Percent Score = 81.0% Percent Pass Score = 80.0% Test Result = Passed Input Test Run 2 (User input is shown in bold) Enter Percent Pass Score: 80 Enter Maximum Test Score: 400 Enter User Test Score: 316 Output Test Run 2 Result Summary Maximum Score = 400 User Test Score = 316 User Percent Score = 79.0% Percent Pass Score = 80.0% Test Result = Failed Implementation Discussion Operators: Arithmetic operators + - * / % operands: int (all), char (+, -), double (+, -, *, /) Arithmetic expression: evaluates to int/double/char Compare Operators <, >, == , !=, >=, <= operands: int, double, char Compare expressions: Evaluates to boolean type. Logical Operators ||, &&, ! operands: boolean Logical Expressions: Evaluates To boolean type. Assignment Operator = Variable on LHS and expression on RHS LHS (variable) = RHS (expression) Evalutes right to left. Operands Assignment Expression;
 ``1234567891011121314151617181920212223242526`` ``````#include using namespace std; int main() { const double PERCENT_PASS_SCORE = 80, MAXIMUM_TEST_SCORE = 400; double int userPercentScore, userTestScore = 0; userPercentScore == MAXIMUM_TEST_SCORE / userTestScore; if(PERCENT_PASS_SCORE>=userPercentScore) else { } return 0; }``````
Ok, here is an update. I suppose I'm still confused on how to alter the "test result" without making it a constant. Or at least that's what the professor is asking for. Heres the updated code that I'm still having problems with.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142`` ``````#include using namespace std; int main() { double PERCENTPASSSCORE; double MAXIMUMTESTSCORE; double userTestScore; double userPercentScore; cout << "Enter Percent Pass Score: "<> PERCENTPASSSCORE >>endl; cout << "Enter Maximum Test Score: "<> MAXIMUMTESTSCORE >>endl; cout << "Enter User Test Score: " <> userTestScore >>endl; userPercentScore = MAXIMUMTESTSCORE/userTestScore * 100% if (PERCENTPASSSCORE>=80%&&TestResult==passed) else (PERCENTPASSSCORE<=80%&&TestResult==failed) cout << "Result Summary" <
This is working solution. If you have any questions to how this works feel free to ask

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061`` ``````#include #include #include using namespace std; int main() { double PERCENTPASSSCORE; double MAXIMUMTESTSCORE; double userTestScore; double userPercentScore; short p; cout << "Enter Percent Pass Score: "; cin >> PERCENTPASSSCORE; cout << endl; cout << "Enter Maximum Test Score: "; cin >> MAXIMUMTESTSCORE; cout << endl; cout << "Enter User Test Score: "; cin >> userTestScore; cout << endl; userPercentScore = userTestScore/MAXIMUMTESTSCORE * 100; if (userPercentScore >= PERCENTPASSSCORE) { p = 1; } else { p = 2; } cout << "Result Summary" <
Last edited on
Topic archived. No new replies allowed.