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 C++ program using Visual Studio that could be used by a college to track...
create a C++ program using Visual Studio that could be used by a college to track its courses. In this program, create a CollegeCourse class includes fields representing department, course number, credit hours, and tuition. Create a child (sub class) class named LabCourse, that inherits all fields from the the CollegeCourse class, includes one more field that holds a lab fee charged in addition to the tuition. Create appropriate functions for these classes, and write a main() function that instantiates...
Write a C-based language program in visual studio that uses an array of structs that stores...
Write a C-based language program in visual studio that uses an array of structs that stores student information including name, age, GPA as a float, and grade level as a string (e.g., “freshmen,”). Write the same program in the same language without using structs.
VISUAL STUDIO CODE Use a for loop for to create "password". Request the password at least...
VISUAL STUDIO CODE Use a for loop for to create "password". Request the password at least 3 times. If the password is 12345, the procedure ends, if the correct password entered, close excel saving changes. THANKS
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...
In C++ using a single dimensional array Create a program that uses a for loop to...
In C++ using a single dimensional array Create a program that uses a for loop to input the day, the high temperature, and low temperature for each day of the week. The day, high, and low will be placed into three elements of the array. For each loop the day, high, and low will be placed into the next set of elements of the array. After the days and temps for all seven days have been entered into the array,...
Microsoft Visual C++ Assembly language Problem 3. Write a program that uses a loop to calculate...
Microsoft Visual C++ Assembly language Problem 3. Write a program that uses a loop to calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(1) = 1, Fib(2) = 2, … Fib(n) = Fib(n-1) + Fib(n-2). Place each value in the EAX register and display it with a call DumpRegs statement inside the loop For example: Fib(1) = 1, Fib(2) = 2, Fib(3) = Fib(1) + Fib(2) = 3, Fib(4) = Fib(2) + Fib(3)...
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...
answer the following using C# Design and program a Visual Studio Console project in C# that...
answer the following using C# Design and program a Visual Studio Console project in C# that allows your user to enter a number. The program will examine the number to see if it is prime. If it is prime, it will print the next higher prime and the next lower primes to the console. If the number entered by the user is not prime, display a message to that effect. All code should be written by you. Do not copy/paste...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT