Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- double TData[2][7];
- void getData(){
- cout<<"Please input the highest temperature of every day respectively this week."<<endl;
- for(int i=0;i<7;++i){
- cin>>TData[0][i];
- }
- cout<<"Please input the lowest temperature of every day respectively this week."<<endl;
- for(int i=0;i<7;++i){
- cin>>TData[1][i];
- }
- }
- void averageHigh(){
- double avgHigh=0;
- for(int i=0;i<7;++i){
- avgHigh+= TData[0][i];
- }
- avgHigh=avgHigh/7.0;
- cout<<"The average high temperature this week is: "<<avgHigh<<endl;
- }
- void averageLow(){
- double avgLow=0;
- for(int i=0;i<7;++i){
- avgLow+= TData[1][i];
- }
- avgLow=avgLow/7.0;
- cout<<"The average low temperature this week is: "<<avgLow<<endl;
- }
- void indexHighTemp(){
- double highT=0.0;
- for(int i=0;i<7;++i){
- if(highT<TData[0][i]){
- highT=TData[0][i];
- }
- }
- cout<<"The highest temperate this week is: "<<highT<<endl;
- }
- void indexLowTemp(){
- double LowT=0.0;
- for(int i=0;i<7;++i){
- if(LowT>TData[1][i]){
- LowT=TData[1][i];
- }
- }
- cout<<"The lowest temperate this week is: "<<LowT<<endl;
- }
- int main()
- {
- getData();
- averageHigh();
- averageLow();
- indexHighTemp();
- indexLowTemp();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement