Write a program that presents seven proverbs

Assignment Help Business Management
Reference no: EM132260993

This the question

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

I have problem in my coding. I do not why I'm keep making a mistake. This is my code. Please someone explain to me why I'm doing wrong. Can someone explain to me step by step?

#include <iostream>

#include <string>

using namespace std;

bool provout (int i);

void finalout (int correct);

int main (void)

{

  string prov1 = "The squeaky wheel gets the grease";

  string prov2 = "Cry and you cry alone";

  string prov3 = "Opposites attract";

  string prov4 = "Spare the rod and spoil the child";

  string prov5 = "Actions speak louder than words";

  string prov6 = "Familiarity breeds contempt";

  string prov7 = "Marry in haste, repent at leisure";

  bool ans = 0;

  int total = 0;

  for (int i = 0; i < 7; i++)

  {

    switch (i)

    {

    case 0 :

       {

         cout << prov1 << endl;

         ans = provout (i);

         break;

       }

    case 1 :

       {

         cout << prov2 << endl;

         ans = provout (i);

         break;

       }

    case 2 :

      {

        cout << prov3 << endl;

        ans = provout (i);

        break;

      }

    case 3 :

      {

        cout << prov4 << endl;

        ans = provout (i);

        break;

      }

    case 4 :

      {

        cout << prov5 << endl;

        ans = provout (i);

        break;

      }

    case 5 :

      {

        cout << prov6 << endl;

        ans = provout (i);

        break;

      }

    case 6 :

      {

        cout << prov7 << endl;

        ans = provout (i);

        break;

       }

    }

  total = total + ans;

   }

finalout (total);

 

return 0;

}

bool provout (int i)

{

  bool ans = 0;

  bool ok = 0;

 

  cout << "Please answer 1 for True or 0 for False ";

  cin >> ans;

  switch (i)

  {

  case 0 :

  {

    if (ans == 1)

      ok = 1;

    else

      ok = 0;

    break;

  }

  case 1 :

   {

     if (ans == 1)

       ok = 1;

     else

       ok = 0;

  }

  case 2 :

    {

      if (ans == 0)

        ok = 1;

      else

        ok = 0;

      break;

    }

  case 3 :

    {

      if (ans == 0)

        ok = 1;

      else

        ok = 0;

      break;

    }

  case 4 :

    {

      if (ans == 1)

        ok = 1;

      else

        ok = 0;

      break;

    }

  case 5 :

    {

      if (ans == 0)

        ok = 1;

      else

        ok = 0;

      break;

    }

  case 6 :

    {

      if (ans == 1)

        ok = 1;

    }

  }

return ok;

}

void finalout (int correct)

{

  switch (correct)

  {

  case 7 :

    {

      cout << "Excellent!n";

      break;

    }

  }

}

Reference no: EM132260993

Questions Cloud

Determine which number is the smallest : Determine which number is the smallest. Print that number along with some descriptive text to inform the user of what is being printed to the screen.
Risk stratification-patient engagement and outreach : What is the role of EHRs, registries, risk stratification, patient engagement and outreach, care coordination and management, analytics,
Please write c++ program that reads : Please write C++ program that reads a local election result file (called "votes.txt"):
The purpose of the negotiation process is simple : “Let me be one of fifteen men at a table, and I will have my way” was stated by. The purpose of the negotiation process is simple.
Write a program that presents seven proverbs : 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.
Decision-making methodology in business : GIIM 619 Marketing Management - Concordia University - An effective problem-solving/decision-making methodology in business incorporates
What are the basic data definition commands : What are some of the things you can accomplish with a data definition command?
Drawback of warehouses consolidation in distribution network : What is the problem addressed in this paper? What are the benefits and drawbacks of warehouses consolidation in a distribution network?
Output the repayment schedule : A $40,000 , 6 month, 5% annual rate car loan is obtained on June 1. Output the repayment schedule with

Reviews

Write a Review

Business Management Questions & Answers

  Government and business budget making

Describe and discuss the apparent differences between government and business budget making.

  Examine apples position on companys ethical responsibilities

Examine Apple's current position on the company's ethical and social responsibilities, and determine whether or not the company has met these responsibilities. Provide two examples that support your position.

  Potential applications to health care project management

Based on this resource, write an overview on Project 2010, and its potential applications to health care project management. Include the following:

  Utilize research and correlation to textbook topics

Give an overview of this subject's background, utilize research and correlation to textbook topics to show: subject's growth into leadership characteristics that led to his or her leadership capabilities and decision making how will this person's ..

  Elucidate who would benefit most from this action

If all foreign search engine companies declined to invest directly in China due to concerns over censorship, what do you think the results would be? Elucidate who would benefit most from this action? Who would lose the most?

  What are the validity of a strengths

What are the validity of a strengths, weaknesses, opportunities, and threats (SWOT) analysis in strategic planning?

  Determining the progressive tax structure

What type of tax structure do you think is more efficient for an economy to utilize? Do you think a progressive tax structure is efficient for the US economy?

  Explain it is quickly determined that they will need liver

Explain It is quickly determined that they will need liver transplants and many of them are on a waiting list

  Teams can often be fluid and dynamic

Leadership positions within teams can often be fluid and dynamic. Circumstances may require an individual to step forward and lead in some situations and then adopt the role of follower in others.

  Pros and cons of unions

Pros and Cons of Unions-Why do workers join unions? What implications would this have for an organization that wishes to remain non-union

  Hypothesis testing and errors

What is a type I error? What is a type II error? For a test at the 95% confidence level, what is alpha? What is the power of a statistical test

  Trade-offs related to organizational performance

What impact does this approach have upon logistics costs and manufacturing costs? What are the trade-offs related to organizational performance? Summarize your thoughts in a MS Word (or similar application) document. Your answer should be at least..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd