Question

INTERMEDIATE 23. If necessary, create a new project named Intermediate23 Project and save it in the Cpp8 Chap12 folder. Also create a new source file named Intermediate23.cpp. Declare a seven-row, two-column int array named temperatures. The program should prompt the user to enter the highest and lowest temperatures for seven days. Store the highest temperatures in the first column in the array. Store the lowest temperatures in the second column. The program should display the average high temperature and the average temperature. Display the average temperatures with one place. Save and then run the program. Test the program using the data shown in Figure 12-19. Day 95 67 98 54 70 86 99 56 34 83 75 68 45 80 Figure 12-19

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <iomanip> // std::setprecision
using namespace std;

int main()
{
// Declaring variables
int rows = 7;
int cols = 2;

// Declaring variable
int temps[rows][cols];

/* getting the highest and lowest
* temperatures entered by the user
*/
for (int i = 0; i < rows; i++)
{
cout << "Day#" << i + 1 << endl;
for (int j = 0; j < cols; j++)
{
if (j == 0)
{
cout << "Enter the Highest Temperature :";
cin >> temps[i][j];
}
else if (j == 1)
{
cout << "Enter the Lowest Temperature :";
cin >> temps[i][j];
}
}
}

// Displaying the data in table format
cout << "\nDay\tHighest\tLowest" << endl;
cout << "---\t-------\t------" << endl;
for (int i = 0; i < rows; i++)
{
cout << i + 1 << "\t";
for (int j = 0; j < cols; j++)
{
cout << temps[i][j] << "\t";
}
cout << endl;
}

int sum = 0;
double average = 0.0;

// Setting the precision to one decimal
std::cout << std::setprecision(1) << std::fixed;
cout << "\nAverage\t";

/* This for loop will calculate the average
* of highest and lowest temperatures
*/
for (int j = 0; j < cols; j++)
{

for (int i = 0; i < rows; i++)
{
sum += temps[i][j];
}
cout << ((double)sum / rows) << "\t";
sum = 0;
}


return 0;
}

______________________

Output:

CProgram Files (x86)\Dev-Cpp MinGW64\bin TemperatureHighestlowestin7rows2ColsArray.exe Day#1 Enter the Highest Temperature 95


______________Thank You

Please rate me well.If you area satisfied.

Add a comment
Know the answer?
Add Answer to:
If necessary, create a new project named Intermediate23 Project and save it in the Cpp8\Chap12 folder....
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • If necessary, create a new project named Intermediate24 Project and save it in the Cpp8\Chap14 folder....

    If necessary, create a new project named Intermediate24 Project and save it in the Cpp8\Chap14 folder. Also create a new source file named Intermediate24.cpp. If you are using Microsoft Visual C++, copy the Intermediate24.txt file from the Cpp8\Chap14 folder to the Cpp8\Chap14\Intermediate24 Project folder. Use a text editor to open the Intermediate24.txt file, which contains payroll codes and salaries. Close the Intermediate24.txt file. Create a program that allows the user to enter a payroll code. The program should search for...

  • chapter 7. Create a program that allows the user to enter the ages (in years) of...

    chapter 7. Create a program that allows the user to enter the ages (in years) of five people. The program should display the average age. Use the for the statement. Display the average age with one decimal place. If necessary, create a new project named TryThis15 Project, and save it in the Cpp8\Chap07 folder. Enter the C++ instructions into a source file named TryThis15.cpp. Also, enter appropriate comments and any additional instructions required by the compiler. Test the program using...

  • Can someone help me with a c++ program Create a program that displays a measurement in...

    Can someone help me with a c++ program Create a program that displays a measurement in either inches or centimeters. If necessary, create a new project named Introductory 18 Project, and save it in the Cpp8\Chap09 folder. The program should allow the user the choice of converting a measurement from inches to centimeters or vice versa. Use two program-defined functions: one for each different conversion type. Enter your C++ instructions into a source file named Introductory 18.cpp Also enter appropriate...

  • C++ The manager of Keystone Tile wants an application that displays the area of a rectangular...

    C++ The manager of Keystone Tile wants an application that displays the area of a rectangular floor, given its measurements in feet. It should also display the total cost of tiling the floor, given the price per square foot of tile. 1-Create a new project named Intermediate13 Project, and save it in the Cpp8\Chap04 folder. Enter your C++ instructions into a source file named Intermediate13.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Test the program...

  • please help with this. You must create a sales tracking program named SalesTracking.java. This program must...

    please help with this. You must create a sales tracking program named SalesTracking.java. This program must track monthly sales as well as compute average yearly sales, total sales for the year, and which month had the highest sales and which month had the lowest sales. The program should prompt the user for the sales for each month starting with January. After all the monthly sales have been entered, your program should have methods that do the following. getSales(): This method...

  • Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student...

    Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student gradebook using a two-dimensional array. It should allow the user to enter the number of students and the number of assignments they wish to enter grades for. This input should be used in defining the two-dimensional array for your program. For example, if I say I want to enter grades for 4 students and 5 assignments, your program should define a 4 X 5...

  • In this project you will create a console C++ program that will have the user to...

    In this project you will create a console C++ program that will have the user to enter Celsius temperature readings for anywhere between 1 and 365 days and store them in a dynamically allocated array, then display a report showing both the Celsius and Fahrenheit temperatures for each day entered. This program will require the use of pointers and dynamic memory allocation. Getting and Storing User Input: For this you will ask the user how many days’ worth of temperature...

  • Step 1: Getting Started Create a new .java file named Lab12.java. At the beginning of this...

    Step 1: Getting Started Create a new .java file named Lab12.java. At the beginning of this file, include your assignment documentation code block. After the documentation block, you will need several import statements. import java.util.Scanner; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; Next, declare the Lab12 class and define the main function. public class Lab12 { public static void main (String [] args) { Step 2: Declaring Variables For this section of the lab, you will need to declare...

  • *Answer must be in C* Write a complete program as follows (declare any necessary variables): Create...

    *Answer must be in C* Write a complete program as follows (declare any necessary variables): Create an array of doubles named “hummus” with 2 rows and 300 columns. Initialize all array elements to zero. Write a loop that will repeatedly ask the user to enter a value and store it in the first row of the array (do not overwrite previously entered values) until the whole first row is populated with the user input. (hint the loop should have the...

  • - Create a folder called pgm1 - In your folder pgm1, USING A WINDOWS EDITOR, create...

    - Create a folder called pgm1 - In your folder pgm1, USING A WINDOWS EDITOR, create a java program named Your lastName, firstLetterOfYourFirstName, pgm1W.java that will do the following: Start here - From your main method call a new method named: processArray - In the processArray method, create one 10x10 two dimensions array named twoDarray - In each index of your twoDarray, load the multiplication of its corresponding xy locations - Using the printf java command display, in a perfect...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT