!!!!!!!!!!!!!PLEASE I NEED THIS IN PSEUDOCODE &&&&& C++!!!!!!!!!!!!!!!! I have a
ID: 3698373 • Letter: #
Question
!!!!!!!!!!!!!PLEASE I NEED THIS IN PSEUDOCODE &&&&& C++!!!!!!!!!!!!!!!!
I have a pseudocode that I did myself but it will not run properly!!
Step 1: Complete the existing pseudocode using the Main() procedure only. The only other procedures will be Housekeeping() and EndOfJob(). Use the array, rainfall, to:
Enter the monthly rainfall for each of 12 months.
Output the rainfall for each month.
Store those values in the array, rainfall
Determine the total rainfall for the year. Output this amount with an appropriate message.
Determine the average monthly rainfall. Output this average.
Determine the month number with the highest rainfall. Output the month number and the amount of rainfall.
Determine the month number with the lowest rainfall. Output both the month number and the amount of rainfall.
Step 2: Implement and test your design using C++. Use the C++ template provided.
For your test data use the following monthly rainfall data for Austin, Texas from 2010
Jan 3.29 Feb 2.81 Mar 2.79
Apr 1.44 May 1.01 Jun 4.15
July 5.37 Aug 0.63 Sep 5.15
Oct 0.06 Nov 0.92 Dec 0.80
Be sure month values go from 1 to 12 in output.
Explanation / Answer
#include <iostream>
using namespace std;
float rainfall[12];
void inputData(float rainfall[])
{
for(int i=0;i<12;i++)
{
cout<<"Enter rainfall for month "<<i+1<<" : ";
cin>>rainfall[i];
}
}
void display(float rainfall[])
{
float min=999,max=0,minMonth,maxMonth,total;
cout<<" ******Rainfall for the year***** ";
for(int i=0;i<12;i++)
{
total+=rainfall[i];
cout<<" "<<i+1 <<" "<<rainfall[i];
if(rainfall[i]<min)
{
min=rainfall[i];
minMonth=i;
}
if(rainfall[i]>max)
{
max=rainfall[i];
maxMonth=i;
}
}
cout<<" Total rainfall of the year: "<<total;
cout<<" Average rainfall of the month: "<<total/12;
cout<<" Maximum rainfall of the year is: "<<max<<" for the month of "<<maxMonth+1<<". ";
cout<<" Minimum rainfall of the year is: "<<min<<" for the month of "<<minMonth+1<<". ";
}
int main()
{
inputData(rainfall);
display(rainfall);
return 0;
}
you didnt provide the housekeeping and endofjob methods
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.