Purpose. Learn how to search an array, to count matching values. Requirements. Modify Exercise 11.2's myCity3.cpp, adding loops to count how many times the high temperature occurs and how may times the low temperature occurs. Output the results. Name the new program myCity4.cpp. Here are the changes from v.3.0: 1. Prompt the user for the 5 temperatures. 2. Count the number of times the high and low temperatures occur. In the output say "once" or "one time" if the count is only one. Otherwise say something like "2 times". 3. Use additional variables to avoid typing the city name and the days more than once each. 4. Do not output the source. Program I/O. Input console input of 5 daily high temperatures. Output same as v.3.0, adding counts Example. The output should look something like: Enter the high for San Jose on Wednesday, Aug 25: 79 Thursday, Aug 26: 80 Enter the high for San Jose on Enter the high for San Jose on Friday, Aug 27: 80 Enter the high for San Jose on Saturday, Aug 28: 76 Enter the high for San Jose on Sunday, Aug 29: 71 San Jose forecast high temperatures: Wednesday, Aug 25, 79 degrees Thursday, Aug 26, 80 degrees Friday, Aug 27, 80 degrees Saturday, Aug 28, 76 degrees Sunday, Aug 29, 71 degrees The high for the week is 80 degrees, occurring 2 times The low for the week is 71 degrees, occurring once

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 #include <iostream>

using namespace std;

 

int main()

{

  cout << "San Jose, California forecast high temperatures: " << endl; 

 

  int temp[5]= {86,81,73,77,79};

 

  

 

cout << "Monday, September 26, "  << temp[0] << " degrees" <<  endl;

 

cout << "Tuesday, September 27, " << temp[1] << " degrees" << endl;

 

cout << "Wednesday, September 28, " << temp[2] << " degrees" << endl;

 

cout << "Thursday, September 29, " << temp[3] << " degrees" << endl;

 

cout << "Friday, September 30, " << temp[4] << " degrees" << endl;

 

  int minimum = temp[0];

  int maximum = temp[0];

 

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

  {

 

  if (minimum > temp[i])

  {

    minimum = temp[i];

    }

  if (maximum < temp[i])

  {

    maximum = temp[i];

 

      }

  }

 

cout << endl;  

 

cout << "The high for the week is " << maximum << endl;

 

cout <<  "The low for the week is " << minimum << endl; 

 

cout << endl;

 

cout << "source: Weather.com " << endl;

  

}

// I've attached the (city3.cpp) source code that needs to be modified. Please pay attention to the instruction. If possible don't publish my source code please.

My City, v.4.0
Purpose. Learn how to search an array, to count matching values.
Requirements. Modify Exercise 11.2's myCity3.cpp, adding loops to count how many times the
high temperature occurs and how may times the low temperature occurs. Output the results. Name
the new program myCity4.cpp.
Here are the changes from v.3.0:
1. Prompt the user for the 5 temperatures.
2. Count the number of times the high and low temperatures occur. In the output say
"one time" if the count is only one. Otherwise say something like "2 times".
3. Use additional variables to avoid typing the city name and the days more than once each.
4. Do not output the source.
Program I/O. Input console input of 5 daily high temperatures. Output same as v.3.0, adding counts.
Example. The output should look something like:
Enter the high for San Jose on Wednesday, Aug 25: 79
Enter the high for San Jose on Thursday, Aug 26: 80
Enter the high for San Jose on
Enter the high for San Jose on Saturday, Aug 28: 76
Enter the high for San Jose on Sunday, Aug 29: 71
Friday, Aug 27: 80
San Jose forecast high temperatures:
Wednesday, Aug 25, 79 degrees
Thursday, Aug 26, 80 degrees
Friday, Aug 27, 80 degrees
Saturday, Aug 28, 76 degrees
Sunday, Aug 29, 71 degrees
The high for the week is 80 degrees, occurring 2 times
The low for the week is 71 degrees, occurring once
"once" or
Transcribed Image Text:My City, v.4.0 Purpose. Learn how to search an array, to count matching values. Requirements. Modify Exercise 11.2's myCity3.cpp, adding loops to count how many times the high temperature occurs and how may times the low temperature occurs. Output the results. Name the new program myCity4.cpp. Here are the changes from v.3.0: 1. Prompt the user for the 5 temperatures. 2. Count the number of times the high and low temperatures occur. In the output say "one time" if the count is only one. Otherwise say something like "2 times". 3. Use additional variables to avoid typing the city name and the days more than once each. 4. Do not output the source. Program I/O. Input console input of 5 daily high temperatures. Output same as v.3.0, adding counts. Example. The output should look something like: Enter the high for San Jose on Wednesday, Aug 25: 79 Enter the high for San Jose on Thursday, Aug 26: 80 Enter the high for San Jose on Enter the high for San Jose on Saturday, Aug 28: 76 Enter the high for San Jose on Sunday, Aug 29: 71 Friday, Aug 27: 80 San Jose forecast high temperatures: Wednesday, Aug 25, 79 degrees Thursday, Aug 26, 80 degrees Friday, Aug 27, 80 degrees Saturday, Aug 28, 76 degrees Sunday, Aug 29, 71 degrees The high for the week is 80 degrees, occurring 2 times The low for the week is 71 degrees, occurring once "once" or
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

When we output the high or low temperature if it's occuring once it should say occuring "once" instead of 1 time. also, the program must use additional variables to avoid typing the city name and the days more than once each.

My City, v.4.0
Purpose. Learn how to search an array, to count matching values.
Requirements. Modify Exercise 11.2's myCity3.cpp, adding loops to count how many times the
high temperature occurs and how may times the low temperature occurs. Output the results. Name
the new program myCity4.cpp.
Here are the changes from v.3.0:
1. Prompt the user for the 5 temperatures.
2. Count the number of times the high and low temperatures occur. In the output say "once" or
"one time" if the count is only one. Otherwise say something like "2 times".
3. Use additional variables to avoid typing the city name and the days more than once each.
4. Do not output the source.
Program I/O. Input console input of 5 daily high temperatures. Output same as v.3.0, adding counts.
Example. The output should look something like:
Enter the high for San Jose on Wednesday, Aug 25: 79
Enter the high for San
Thursday, Aug 26: 80
Jose on
Jose on
Enter the high
for San
Friday, Aug 27: 80
Enter the high for San
Jose on
Saturday, Aug 28: 76
Enter the high for San Jose on Sunday, Aug 29: 71
San Jose forecast high temperatures:
Wednesday, Aug 25, 79 degrees
Thursday, Aug 26, 80 degrees
Friday, Aug 27, 80 degrees
Saturday, Aug 28, 76 degrees
Sunday, Aug 29, 71 degrees
The high for the week is 80 degrees, occurring 2 times
The low for the week is 71 degrees, occurring once
Transcribed Image Text:My City, v.4.0 Purpose. Learn how to search an array, to count matching values. Requirements. Modify Exercise 11.2's myCity3.cpp, adding loops to count how many times the high temperature occurs and how may times the low temperature occurs. Output the results. Name the new program myCity4.cpp. Here are the changes from v.3.0: 1. Prompt the user for the 5 temperatures. 2. Count the number of times the high and low temperatures occur. In the output say "once" or "one time" if the count is only one. Otherwise say something like "2 times". 3. Use additional variables to avoid typing the city name and the days more than once each. 4. Do not output the source. Program I/O. Input console input of 5 daily high temperatures. Output same as v.3.0, adding counts. Example. The output should look something like: Enter the high for San Jose on Wednesday, Aug 25: 79 Enter the high for San Thursday, Aug 26: 80 Jose on Jose on Enter the high for San Friday, Aug 27: 80 Enter the high for San Jose on Saturday, Aug 28: 76 Enter the high for San Jose on Sunday, Aug 29: 71 San Jose forecast high temperatures: Wednesday, Aug 25, 79 degrees Thursday, Aug 26, 80 degrees Friday, Aug 27, 80 degrees Saturday, Aug 28, 76 degrees Sunday, Aug 29, 71 degrees The high for the week is 80 degrees, occurring 2 times The low for the week is 71 degrees, occurring once
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education