Question

c++ Proverbs Test Using the table below, write a program that presents these seven proverbs one...

c++

Proverbs Test

Using the table below, write a program that presents these seven proverbs one at a time and asks the user to evaluate them as true or false. The program should then tell the user how many questions were answered correctly, and display one of the following evaluations: Perfect (all seven answers correct), Excellent (5 or 6 correct), You might want to consider taking Psychology 101 (less than 5 correct).

Proverb                             Truth Value

The squeaky wheel gets the grease       True

Cry and you cry alone                           True

Opposites attract                      False

Spare the rod and spoil the child           False

Actions speak louder than words           True

Familiarity breeds contempt                  False

Marry in haste, repent at leisure            True

You must utilize at least two switch statements and three functions (including main) in your solution.

One solution could look like this, yours might be different:

main

       switch statement to present each of the proverbs in order

       function call to func1 to process the answers, returning either true or false

       accumulate correct answer total

       function call to func2 to output the results, pass in total correct

func1

       ask user for answer, return true or false

func2

       switch statement to output results

              7 correct == perfect

              5 or 6 correct == excellent

              < 5 correct == you should take Psychology 101

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ Program:

#include <iostream>
#include <string>

using namespace std;

string answers[] = {"True", "True", "False", "False", "True", "False", "True"};

//Function checkAnswer
int chkAnswer(string userAnswer, int idx)
{
//Checking answer
if(userAnswer == answers[idx])
return 1;
else
return 0;
}

//Function that produces the result
void produceResult(int score)
{
switch(score)
{
case 7: cout << "\nPerfect\n"; break;

case 6:
case 5:
cout << "\nExcellent\n"; break;

case 4:
case 3:
case 2:
case 1:
case 0: cout << "\nYou should take Psychology 101\n"; break;
}
}

//Main function
int main()
{
string userAnswer;
int i;
int score = 0 ;

//Displaying questions one by one
for(i=1; i<=7; i++)
{
switch(i)
{
case 1: cout << "\n The squeaky wheel gets the grease: ";
break;
case 2: cout << "\n Cry and you cry alone: ";
break;
case 3: cout << "\n Opposites attract: ";
break;
case 4: cout << "\n Spare the rod and spoil the child: ";
break;
case 5: cout << "\n Actions speak louder than words: ";
break;
case 6: cout << "\n Familiarity breeds contempt: ";
break;
case 7: cout << "\n Marry in haste, repent at leisure: ";
break;
}

//Checking user answer
cin >> userAnswer;

if(chkAnswer(userAnswer, i) == 1)
{
score = score + 1;
}
}

//Checking result
produceResult(score);

cout << endl << endl;
return 0;
}

___________________________________________________________________________________________________

Sample Run:

Add a comment
Know the answer?
Add Answer to:
c++ Proverbs Test Using the table below, write a program that presents these seven proverbs one...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C/C++ program that simulate a menu based binary number calculator. This calculate shall have the following three...

    Write a C/C++ program that simulate a menu based binary number calculator. This calculate shall have the following three functionalities: Covert a binary string to corresponding positive integers Convert a positive integer to its binary representation Add two binary numbers, both numbers are represented as a string of 0s and 1s To reduce student work load, a start file CSCIProjOneHandout.cpp is given. In this file, the structure of the program has been established. The students only need to implement the...

  • Can you please help me with creating this Java Code using the following pseudocode? Make Change C...

    Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.)                                                                                                                                  2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...

  • Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate...

    Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...

  • Please use Java to write the program The purpose of this lab is to practice using...

    Please use Java to write the program The purpose of this lab is to practice using inheritance and polymorphism. We need a set of classes for an Insurance company. Insurance companies offer many different types of policies: car, homeowners, flood, earthquake, health, etc. Insurance policies have a lot of data and behavior in common. But they also have differences. You want to build each insurance policy class so that you can reuse as much code as possible. Avoid duplicating code....

  • I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instruction...

    I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT