Question

This is a very short trivia game. See if the user can guess the year that...

This is a very short trivia game. See if the user can guess the year that MDC (formerly Dade County Junior College) first started offering classes (1960). If the user guesses incorrectly, ask if they want another attempt. Once the user gets it right, report the number of guesses needed and end the program.

Initial Output:

MDC was originally named Dade County Junior College.

Output (per loop)

In what year were classes first offered? [user types: 1980]

That answer is incorrect. Do you want to try again? [user types: y]

In what year were classes first offered? [user types: 1960]

Your answer is correct! It took you 2 tries to guess it.

Notes and Hints:

1) You can use whatever loop you feel is best

2) You must accept the upper and lower case versions of Y and N in the user's reply

3) The program must end when the user gets it right. Do not ask if they want to continue.

Starter Code:

// CONSTANTS AND VARIABLES
  
// INITIAL MESSAGE
std::cout << "MDC was originally named Dade County Junior College.\n";

// LOOP WHILE USER WANTS TO KEEP GUESSING
  
std::cout << "In what year were classes first offered? ";
  
std::cout << std::endl; // For Mimir

std::cout << "That answer is incorrect. Do you want to try again? ";

std::cout << std::endl; // For Mimir

std::cout << "Your answer is correct! It took you " << YOUR_CODE << " tries to guess it.";
  

Homework Answers

Answer #1

#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
int year,i=0;
char ch;
cout << "MDC was originally named Dade County Junior College.\n";
do{
i++;
cout << "In what year were classes first offered? ";
cin>>year;
if(year==1960)
{
cout<<"Your answer is correct! It took you "<<i<<" tries to guess it.";
ch='n';
}
else{
cout<<"That answer is incorrect. Do you want to try again?";
cin>>ch;
}
}while(ch=='y'|| ch=='Y');
}

Know the answer?
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
Similar Questions
Create a very simple TCP Application in JAVA. You will create a client and a server....
Create a very simple TCP Application in JAVA. You will create a client and a server. The client must execute after you start the server. Here is what they will do. The client will read from the console a string that the users enters. This string will be the name of the user, let's say Bob. The client then sends the name, Bob, in an Object Stream, to the server. The server will receive this Object Stream and send to...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
In this assignment you will write a program that compares the relative strengths of two earthquakes,...
In this assignment you will write a program that compares the relative strengths of two earthquakes, given their magnitudes using the moment magnitude scale. Earthquakes The amount of energy released during an earthquake -- corresponding to the amount of shaking -- is measured using the "moment magnitude scale". We can compare the relative strength of two earthquakes given the magnitudes m1 and m2 using this formula: f=10^1.5(m1−m2) If m1>m2, the resulting value f tells us how many times stronger m1...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT