Question

Write   a   CPP   application   that   counts   the   number   of   days   that   the   temperature   is   above&nb

Write   a   CPP   application   that   counts   the   number   of   days   that   the   temperature   is   above   average.   Read   ten   temperatures   from   the   keyboard   and   place   them   in   as   array.   Compute   the   average   temperature   and   then   count   and   display   the   number   of   day   on   which   the   temperature   was   above   average.  
  

C++ code

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

C++ CODE:

#include <iostream>
using namespace std;
int main(){
    float temps[10];
    float avg = 0.0f;
    int count = 0;
    // Read 10 temperatures from the user
    for(int i = 0; i < 10; i++){
        cout << "Enter temperature on day " << i + 1 << ": ";
        cin >> temps[i];
        avg += temps[i];
    }
    avg /= 10;
    // Count how many temperatures are above average
    for(int i = 0; i < 10; i++){
        if(temps[i] > avg)
            count++;
    }
    // Output
    cout << "Number of days on which the temperature was above average: " << count << endl;
    return 0;
}

SAMPLE OUTPUT:

FOR ANY HELP JUST DROP A COMMENT

Add a comment
Know the answer?
Add Answer to:
Write   a   CPP   application   that   counts   the   number   of   days   that   the   temperature   is   above&nb
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
  • Write a C++ console application that reverses an array of characters, and counts the number of:...

    Write a C++ console application that reverses an array of characters, and counts the number of:           Lower case characters (islower)           Upper case characters (isupper)           Digits (isdigit)           Other (not one of previous) Create four global variables to hold these counts. Create function void count(char input[], char reverse[]) that takes as input two arrays: one that contains characters and another that will contain the reverse of that array. The function will reverse the input array and do the...

  • Java --- Write a method to summarise daily tempratures. The details are given as follow. -...

    Java --- Write a method to summarise daily tempratures. The details are given as follow. - The method will receive an array of doubles. Each number in the array represents the temperature of a day. - If there are less than 10 temperatures recorded, the method will not perform any calculation. Instead, it will print a message "Insufficient data". - If there are 10 or more temperature recorded, the method will calculate: -- the average temperature -- the highest temperature...

  • Q1. CLO: (5 points) Write a java program that reads 10 words from the keyboard then...

    Q1. CLO: (5 points) Write a java program that reads 10 words from the keyboard then place them in an array. Display the array elements in reverse order, and then count and print the number of times a word appears in that array. The user shall insert the word from the keyboard.

  • Problem: A local amateur meteorologist has been recording daily high temperatures throughout the month of June....

    Problem: A local amateur meteorologist has been recording daily high temperatures throughout the month of June. He would like you to write a program to compute some statistics based on the data he has collected. He has placed each daily high temperature on a separate line in a file named “summer_temps.txt”. The high temperatures are in order so that the first one is for June 1, the second is for June 2, and so on. The statistics that the meteorologist...

  • Write a program in JavaScript, that take (07) days temperatures from user and display the temperature...

    Write a program in JavaScript, that take (07) days temperatures from user and display the temperature in centigrade, Fahrenheit and kelvin on web browser. Hint: you can use array, for loop .

  • Write an application that does the following: (1) fill a 32-bit array with 10 pseudo-random integers...

    Write an application that does the following: (1) fill a 32-bit array with 10 pseudo-random integers between -50 and +49 ; (2) Loop through the array, displaying each value, and count the number of negative values; (3) After the loop finishes, display the count. Below is an assembly program template that you can refer, and complete the programming by filling in the codes into the specified place: Comment ! Title: Counting Array Values Description: Write an application that does the...

  • Write a program called problem4.cpp that creates a histogram of the temperature values over the past...

    Write a program called problem4.cpp that creates a histogram of the temperature values over the past year. The temperature values ranges from 0 to 25 degrees, and the program should ask the use to input the number of days in the past year where the temperature was of each of these values. After the user inputs this data, the program should draw a histogram of these temperatures using the char ‘*’ and output the mode temperature (the temperature that occurred...

  • A. Write an Array Program Write a main program that counts the number of occurrences of...

    A. Write an Array Program Write a main program that counts the number of occurrences of the number 6.0 in a large array of doubles and then prints out the number of elements in the array and the number of values that are 6.0. Also, compute and print the average value to 7 decimal places of all the elements in the array. 1. Use a for loop. The array fArray [ is defined in a file called Lab8Adatasetx.h that will...

  • C program: Write a program that assigns and counts the number of each alphabetic character in...

    C program: Write a program that assigns and counts the number of each alphabetic character in the Declaration of Independence and sorts the counts from the most used to the least used character. Consider upper and lower case letters the same. The frequency of each character should be accumulated in an array. USE POINTERS to increment counts for each letter, sort your array, and display the results. Output should consist of two columns: (1) each letter 'a'-'z' and (2) the...

  • Please write in java program Write an application that generates 100 random integers between 1 and...

    Please write in java program Write an application that generates 100 random integers between 1 and 75 and writes them to a file named "file_activity.txt". Read the data back from the file and display the following: The sum of the numbers in the file The average of the numbers in the file The numbers in the file in increasing order To sort an array: int[] arr = new int[20]; Arrays.sort(arr); -- this sorts an array To sort an ArrayList: ArrayList<Integer>...

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