Need a prg that lets user enter total rainfal

Assignment Help C/C++ Programming
Reference no: EM13166064

Need a prg that lets user enter total rainfall for each of 12 months into an array of doubles,prg should then calculate and display total rainfall for year,the average monthly rainfall, and the months with highest and lowest amounts

need to use four functions

double getTotal(double[],int);//calculates adn returns total of the values stored in the array parameter;the size parameter indicates the number of elements in the array

double getAverage(doube[],int); //returns the average of the values in the array parameter;the size parameter indicates the number of elements in the array

double getLargest(double[],int,int &);//returns the smallest value in the array parameter and stores the subscript of   the largest value in the element reference parameter

double getSmallest(double[],int,int &);//returns the smallest value in the array parameter and stores the subscript of the smallest value in the element reference parameter

this is what i have but im struggling with arrays and functions please help i know its wrong but i dont know what to fix or even if im on right track

#include<iostream>
#include<string>

using namespace std;

double getTotal(double array[],int monthTotalRain)
{
   string months[]={"January","February","March","April","May","June","July","August","September",

"October","November","December"};
 
   double monthTotalRain[12];
   double totalRainFall=0;
 
   for(int count=0;count<=11;count++)
   {
       cout<<"What is total rainfall for every month? "<<endl;
       cout<<months[count];
       cin>>monthTotalRain[count];
       totalRainFall+=monthTotalRain;
   }
   while monthTotalRain<0)
   {
       cout<<"Please re-enter amount above zero: ";
       cin>>monthTotalRain;
           totalRainFall+=monthTotalRain;
   }
   cout<<"The total amount of rainfall for the year is: "<<totalRainFall<<endl;
   return totalRainFall;
 
}
double getAverage(double array[],int size)
{
   double average;
   average=getTotal[]/size;
   return average;
}
double getLargest(double array[],int size,int &largest)
{
   double highest;
   highest=array[0];
   for(int count=0;count<size;count++)
   {
       if array[count]>highest)
       highest=array[count];
   }
   return highest;

double getSmallest(double array[],int size,int &smallest)
{
   double lowest;
   lowest=array[0];
   for(int count=1;count<size;count++)
   {
       if array[count]<lowest)
       lowest=array[count];
   }
   return lowest;
}


int main()
{
   const int rain=12;
   double rainfall[rain];
   double totalRainYr=0;
   double averageRain;
   string highMonth;
   string lowMonth;
   double highestRain;
   double highest=0;
   double lowest=0;
   double lowestRain;
   double total;
   double average;
 
   total=getTotal(rainfall,rain);
 
   average=getAverage(rainfall,rain);
 
   highestRain=getLargest(rainfall,rain,highest);

   lowestRain=   getSmallest(rainfall,rain,lowest);
 
   cout<<"The lowest amount of rain is "<<lowestRain<<endl;
   cout<<"The highest amount of rain is "<<highestRain<<endl;

   return 0;
}

Reference no: EM13166064

Questions Cloud

State equilibrium ph value of rainwater if atmospheric : What would be the equilibrium pH value of rainwater if atmospheric SO2 gas were its only dissolved constituent? Assume that the fugacity (activity) of SO2 gas in the atmosphere is 5 x 10-9 bar
Relocation hardware costs money : Since relocation hardware costs money, why support relocation? Give at least two reasons? 2) Make arguments for smaller page size on a paging system?
Lives and legacies of the pharaohs hatshepsut : Consider the lives and legacies of the pharaohs Hatshepsut, Akhenaten, and Tutankhamen. If you had to choose, which of these pharaohs would you prefer to be and why?
Acquire from a reference work the solubility of silver : Obtain from a reference work the solubility of silver acetate at 20 degree C. Usually this will be reported in units of grams per 100 mL of water
Need a prg that lets user enter total rainfal : Need a prg that lets user enter total rainfall for each of 12 months into an array of doubles,prg should then calculate and display total rainfall for year,the average monthly rainfall, and the months with highest and lowest amounts
Design a nine-step counter to count using d flip-flops : Design a nine-step counter to count in the following sequence using D flip-flops (TTL 74704) on a breadboard and on verilog: 0011, 0101, 1001, 1000, 1011, 1010, 0110, 0100, 0111, 0011, ... Include in the design a means for resetting the counter to 00..
Law code of hammurabi and laws today : Identify and describe specific differences you notice between the Law Code of Hammurabi and laws today.
You are to design and construct a 3-bit synchronous counter : You are to design and construct a 3-bit synchronous counter with an enable (EN) input. The counter is to count in the prescribed squence shown below if EN is true at the next active clock transition
Write a program to clean up lane9.dat : Write a program to clean up lane9.dat. Write all numbers and spaces to cleanlane9.txt.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create a structure that has one variable called value

"Create a structure that has one variable called value and one pointer to the list (making it a linked list). Prompt for 5 values from the keyboard as input and store them in the linked list. Print out the current contents of the list.

  Write a program that converts between app and ppm values

Write a simple program that converts between APP and PPM values

  Write program function prompt user for number of elements

Write a C++ program main function which will prompt the user for the number of elements called N desired for an array which has the capacity to store 50 elements.

  Prepare an arbitrary sinusoidal waveform

Create a program to compute the derivative of an arbitrary input function, with arbitrary duration and arbitrary limits

  Write a function named largest which will receive the array

Write a function named largest which will receive the array as input and return the variable LargestNumber.

  Implement a semantic analysis

The program will implement Semantic Analysis. The assignment provides two options to define variable scope, either using the Global Option or the Local Option.

  Use a define statement to create a constant

Follow these specifications: Use a define statement to create a constant that will hold your student number. You should have separate string variables for your first and last name; name these first_name and last_name.

  Prompt the user for and read 6 numbers

Write a program using an array that will store input data. Prompt the user for and read 6 numbers between 70 and 90. Verify the numbers should be greater than 70 and less than 90. If the number is less than or equal to 70 or greater than 90, repro..

  Whitewater high school has contracted

Whitewater High School has contracted you to write a program that will read a file of student names and test scores in the formation FIRST NAME LAST NAME: SCORE1 SCORE2 SCORE3, where each of the scores is an integer

  Write a c function that converts a character to upper case.

Write a C function that converts a character to upper case. The function should have the prototype char to_upper(char ch); The characters given as input to the function are assumed to be in the sets {'a', ..., 'z'} and {'A', ... , 'Z' }. Do not use a..

  Write a c program that reads in five numbers

Q1. (Bar Chart /Histogram printing) Write a C program that reads in five numbers (each between 1 and 30). For each number read, your program should print a line containing that number of adjacent asterisks. For example, if your program reads the numb..

  Write function compute square root together with prototype

Write a C++ function called compute together with its prototype that is passed 2 integers, A and B and returns the square root of A2+B2 ,as a double.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd