Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

fatemah

  • 2 years ago

Write a C++ program to enter 24 readings of tempe rature (each reading is between - 5 and 45), compute and print out the average temperature, maximum temperature and minimum temperature of the day. Enforce the necessary validation on the user input. Use proper format for the output.

  • This Question is Open
  1. Shadowys
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    eh? do you have your current attempt? I see decalrations, functions, and while and if loops...

  2. fatemah
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    so how is it solved ???

  3. Shadowys
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    trying to write one now. lol i'm using asking user input to be put into arrays. though i would rather write in python. lol seems like it's working.

  4. Shadowys
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    int main() { int a; int i=0; int temp[24]; while (i<2) { cin>>a; if (a<45) { temp[i]=a; i++; } else { cin.clear(); while (cin.get() != '\n') ; cin>>a; } } } this is the main function where iteration is used to place the values.

  5. Shadowys
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    note that the array simply has 2 values. since i<2. edit this to include 24 values.

  6. Shadowys
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    after putting them in an array, add them together with a while or for function before dividing them by their total number. for max, just write an auto update function that will update when there is a number that is larger than before.

  7. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.