Answer to Question #7056 in C++ for Hanif Halmi

Question #7056
Write a program that will read daily temperature reading for the month of January 2012. Your program should contain the following functions:
(a) main() function contains instructions of reading input needed and print all the related information.
(b) NORMAL() function calculates the number of normal days (temperature between 60F and 84F)
(c) AVERAGE() function calculates the average temperature in January 2012.
(d) DAYS() function calculates
1
Expert's answer
2012-03-13T07:41:04-0400
Dear customer, please state definitely what does DAYS() function calculate.

#include <iostream>
using namespace std;

int i;
int temperature[32];

int NORMAL(){
int res=0;
for (i=1;i<=31;i++){
& if ((temperature[i]>=60) && (temperature[i]<=84)) res++;
}
return res;
}

float AVERAGE(){
float res=0;
for (i=1;i<=31;i++)
& res = res+temperature[i];
return (res/31);
}

void main(){
for (i=1;i<=31;i++){
& cout<<"Enter a day temperature on January "<<i<<": ";
& cin>>temperature[i];
}
cout<<"The number of normal days is "<<NORMAL()<<"\n";
cout<<"The average temperature is "<<AVERAGE()<<"\n";
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS