Question: ********This is the Cengage Error I am getting Tasks 2.50 out of 10.00 Program runs correctly 1 out of 4 checks passed. Review the results
********This is the Cengage Error I am getting
Tasks
2.50 out of 10.00
Program runs correctly
1 out of 4 checks passed. Review the results below for more details.
Checks
Test CaseComplete
Test for Chicago; invalid input
Test CaseIncomplete
Test for Acme
Input
Acme
Output
Enter name of city: Acme The city of Acme is in Michigan.
Results
City found.
Expected Output
City found.
0
Test CaseIncomplete
Test for Watervliet
Input
Watervliet
Output
Enter name of city: Watervliet The city of Watervliet is in Michigan.
Results
City found.
Expected Output
City found.
0
Test CaseIncomplete
Test for Brooklyn
Input
Brooklyn
Output
Enter name of city: Brooklyn The city of Brooklyn is in Michigan.
Results
City found.
Expected Output
City found.
0
// MichiganCities.cpp - This program prints a message for invalid cities in Michigan.
// Input: Interactive
// Output: Error message or nothing
#include
#include
using namespace std;
int main()
{
// Declare variables
string inCity; // name of city to look up in array
const int NUM_CITIES = 10;
// Initialized array of cities
string citiesInMichigan[] = {"Acme", "Albion", "Detroit", "Watervliet", "Coloma", "Saginaw", "Richland", "Glenn", "Midland", "Brooklyn"};
bool foundIt = false; // Flag variable
// Loop control variable
// Get user input
cout << "Enter name of city: ";
cin >> inCity;
// Write your loop here
// Write your test statement here to see if there is
// a match. Set the flag to true if city is found.
for (int i = 0; i < NUM_CITIES; i++) {
if (citiesInMichigan[i] == inCity) {
foundIt = true;
break;
}
}
// Test the flag variable to see if the city was found
if (foundIt) {
cout << "The city of " << inCity << " is in Michigan." << endl;
} else {
cout << "Not a city in Michigan." << endl;
}
// Write your loop here
return 0;
} // End of main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
