1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Reil [10]
3 years ago
12

In this lab, you use what you have learned about searching an array to find an exact match to complete a partially prewritten C

program. The program uses an array that contains valid names for 10 cities in Michigan. You ask the user to enter a city name; your program then searches the array for that city name. If it is not found, the program should print a message that informs the user the city name is not found in the list of valid cities in Michigan. The file provided for this lab includes the input statements and the necessary variable declarations. You need to use a loop to examine all the items in the array and test for a match. You also need to set a flag if there is a match and then test the flag variable to determine if you should print the the Not a city in Michigan. message. Comments in the code tell you where to write your statements. You can use the previous Mail Order program as a guide. Instructions Ensure the provided code file named MichiganCities.cpp is open. Study the prewritten code to make sure you understand it. Write a loop statement that examines the names of cities stored in the array. Write code that tests for a match. Write code that, when appropriate, prints the message Not a city in Michigan.. Execute the program by clicking the Run button at the bottom of the screen. Use the following as input: Chicago Brooklyn Watervliet Acme
Computers and Technology
1 answer:
icang [17]3 years ago
8 0

Answer:

Complete the program as follows:

for(int i = 0; i<10; i++){

     if(inCity == citiesInMichigan[i]){

         foundIt = true;

         break;       }    }

   if(foundIt){         cout<<"It is a city";     }

   else{         cout<<"Not a city";     }

Explanation:

Required

Complete the pre-written code in C++ (as indicated by the file name)

The pre-written code; though missing in this question, can be found online.

The explanation of the added lines of code is as follows:

This iterates through the array

for(int i = 0; i<10; i++){

This checks if the city exists in the array

     if(inCity == citiesInMichigan[i]){

If yes, foundIt is updated to true

         foundIt = true;

And the loop is exited

         break;       }    } -- The loop ends here

If foundIt is true, print it is a city

<em>    if(foundIt){         cout<<"It is a city";     }</em>

Print not a city, if otherwise

<em>    else{         cout<<"Not a city";     }</em>

You might be interested in
Which you could use an Excel chart to present your data?
Svetach [21]
Determining what percentage of customer 101 buys product A, and what percentage of the customer buys product B
6 0
3 years ago
Many mobile computers and mobile devices use LCD monitors. What does LCD stand for?
erica [24]
Liquid crystal display
4 0
3 years ago
What is the relationship between interrupt and buffer <br>​
Jlenok [28]

Answer:

Operating systems have some code called an 'interrupt handler', which prioritises the interrupts and saves them in a queue. Buffers are used in computers as a temporary memory area, and they are essential in modern computers because hardware devices operate at much slower speeds than the processor.

8 0
2 years ago
3k means about 3 thousand bytes. How would you express four trillion bytes?
Elanso [62]
Hello!

Four trillion bytsz will be expressed as "4T".

T stands for trillion.
8 0
3 years ago
What runs horizontally and is identified with numbers?
timama [110]
The answer to this question is C. Row
In excel, The number of Rows will be placed on the Left side of the sheet.
Rows will be utilized together with a column in order to differentiate specific cells with another.
This differentiation will be useful if user wanted to create a certain formula within the sheets
4 0
4 years ago
Read 2 more answers
Other questions:
  • One form of Intrusion Detection System (IDS) starts operation by generating an alert for every action. Over time, the administra
    5·1 answer
  • Are used to connect a computer to a telephone line for dial-up internet access
    5·1 answer
  • Which header provides functions that deal with exceptional conditions?
    13·1 answer
  • You suspect that an attacker has hidden files on your machine. What Linux command would you use to search for files with a file
    14·1 answer
  • Whers the main characteristic of a Peer-to-peer (P2P) network?
    14·1 answer
  • Correct or False, when formatting conditional data, I start by selecting the range of data that I want to format
    9·1 answer
  • 20. The following are considered as ICT skills EXCEPT
    15·1 answer
  • Is there an alternative website of https://phantomtutors.com/ to get guidance in online classes?
    15·1 answer
  • What are ways to create a study schedule? Check all that apply.
    5·2 answers
  • Why aren't my skullcandy bluetooth headphones connecting to my school chromebook if I turned on both the headphones and the blue
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!