Question

In: Computer Science

In visual Studio C++ Create a program that uses a for loop to input the high...

In visual Studio C++ Create a program that uses a for loop to input the high temperature, and low temperature for each day of the week.

The high and low will be placed into two elements of the array.

For each loop the high and low will be placed into the next set of elements of the array.

After the temps for all seven days have been entered into the array, a for loop will be used to pull out the high and low temps and total them.

After all temps have been totaled, the average high and low will be calculated.

The output will display the following; The total high temps is "total high" The total low temps is "total low" The average high temps is "average high" The average low temps is "average low"

Solutions

Expert Solution

Code

#include<iostream>
#include<iomanip>
using namespace std;

const int DAYS_OF_WEEK=7;

int main()
{
   double temp[DAYS_OF_WEEK][2];
   double total_high=0,total_low=0;
   double average_high,average_low;
   for(int i=0;i<DAYS_OF_WEEK;i++)
   {
       cout<<"Enter the high temprature for day "<<(i+1)<<" : ";
       cin>>temp[i][0];
       cout<<"Enter the low temprature for day "<<(i+1)<<" : ";
       cin>>temp[i][1];
       cout<<endl;
   }
   for(int i=0;i<DAYS_OF_WEEK;i++)
   {
       total_high+=temp[i][0];
       total_low+=temp[i][1];
   }
   average_high=total_high/DAYS_OF_WEEK;
   average_low=total_low/DAYS_OF_WEEK;

   cout<<fixed<<setprecision(2);

   cout<<"\nThe total high temps is "<<total_high<<endl;
   cout<<"The total low temps is "<<total_low<<endl;
   cout<<"The average high temps is "<<average_high<<endl;
   cout<<"The average low temps is "<<average_low<<endl;
   return 1;
}

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.


Related Solutions

Create a Visual Studio console project (c++) containing a main() program that declares a const int...
Create a Visual Studio console project (c++) containing a main() program that declares a const int NUM_VALUES denoting the array size. Then declare an int array with NUM_VALUES entries. Using a for loop, prompt for the values that are stored in the array as follows: "Enter NUM_VALUES integers separated by blanks:" , where NUM_VALUES is replaced with the array size. Then use another for loop to print the array entries in reverse order separated by blanks on a single line...
Using C++ language, create a program that uses a struct with array variables that will loop...
Using C++ language, create a program that uses a struct with array variables that will loop at least 3 times and get the below information: First Name Last Name Job Title Employee Number Hours Worked Hourly Wage Number of Deductions Claimed Then, determine if the person is entitled to overtime and gross pay. Afterwards, determine the tax and net pay. Output everything to the screen. Use functions wherever possible. Bonus Points: Use an input file to read in an unknown...
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a...
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a whole paragraph with punctuations (up to 500 letters) either input from user, initialize or read from file and provide following functionalities within a class: a)   Declare class Paragraph_Analysis b)   Member Function: SearchWord (to search for a particular word) c)   Member Function: SearchLetter (to search for a particular letter) d)   Member Function: WordCount (to count total words) e)   Member Function: LetterCount (ONLY to count all...
write in c++ Create a program that uses EXCEPTION HANDLING to deal with an invalid input...
write in c++ Create a program that uses EXCEPTION HANDLING to deal with an invalid input entry by a user. a. Write a program that prompts a user to enter a length in feet and inches. The length values must be positive integers. b. Calculate and output the equivalent measurement in centimeters 1 inch = 2.54 centimeters c. Write the code to handle the following exceptions: If the user enters a negative number, throw and catch an error that gives...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some time and still can't quite figure it out. I'm creating an app that has 2 textboxes, 1 for inputting customer name, and the second for entering the number of tickets the customer wants to purchase. There are 3 listboxes, the first with the days of the week, the second with 4 different theaters, and the third listbox is to display the customer name, number...
Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3...
Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3 text boxes: 2 of them to enter numbers, the 3rd one displays the results Create 4 buttons to add, subtract, multiply, and divide Prevent the user from entering text in the number fields Display a message indicating “cannot divide by” when the user click “/” and there is a zero the in the second box Create two additional buttons: - One to store data...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of project we have been doing all semester.) Do all of the following in the Program class. You do not need to add any other classes to this project. 2. If it exists, remove the Console.WriteLine(“Hello World!”); line that Visual Studio created in the Program class. 3. At the very top of the Program.cs page you should see using System; On the empty line below...
 VISUAL STUDIO (File Creation and Submissions)  FLOWCHART  Writing program in C++ ( cout,...
 VISUAL STUDIO (File Creation and Submissions)  FLOWCHART  Writing program in C++ ( cout, \n, \t, solving expressions )  Correcting errors Q1: Draw flow Chart of the following problems: a) Display “Hello World” on screen. b) Display Your Name, date of birth and mobile number on screen. c) Compute and display the perimeter and area of a rectangle with a height of 7 inches and width of 5 inches. d) Compute and display the perimeter and area...
write a c++ program using micro soft visual studio 2010 to write a program and store...
write a c++ program using micro soft visual studio 2010 to write a program and store 36 in variable x and 8 in variable y. add them and store the result in the variable sum. then display the sum on screen with descriptive text. calculate the square root of integer 36 in x. store the result in a variable. calculate the cube root of integer 8 in y. store result in a variable. display the results of square root and...
Create a C++ project in visual studio. You can use the C++ project that I uploaded...
Create a C++ project in visual studio. You can use the C++ project that I uploaded to complete this project. 1. Write a function that will accept two integer matrices A and B by reference parameters, and two integers i and j as a value parameter. The function will return an integer m, which is the (i,j)-th coefficient of matrix denoted by A*B (multiplication of A and B). For example, if M = A*B, the function will return m, which...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT