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

  Build a traffic light system - microcontroller system

Build the whole system with 3 RAG units and three puffin crossing units and build a team to work on this mini-project, be careful in selecting your team member.

  Write a program that asks the user to enter two numbers.

Starting Out with C++ Write a program that asks the user to enter two numbers.

  Write program which inputs number of winning coupons

Write a program which inputs number of coupons you win and outputs how many candy bars and gumballs you can get if you spend all off your coupons on candy bars first and remaining coupons on gumballs in c++.

  Write program to read from file to find number of integers

Write down the program which reads from file numbers.txt 30 integers in range 0 - 200. Program ‎then determines number of integers in each of given ranges.

  Object-oriented systems is the concept of object

At the heart of all object-oriented systems is the concept of an object. Simply stated, an object is a set of related characteristics and their associated actions.

  Test a program that prompts for the user

Write and test a program that prompts for the user to input a file name and uses two functions head() and tail() - head() displays the first 10 lines of a file

  Create program to input miles driven and gallons used

Create a program in C++ which will input miles driven and gallons used (both as integers) for each tankful. Program must compute and display the miles per gallon

  Print each employee''s identification number

1) in a program you need to store the identification numbers of 10 employees (as ints) and their weekly gross pay (as doubles) A) Define two arrays that may be used in parallel to store the 10 employee indentificcation numbers and gross pay amounts B..

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Write a program to crypt its input accordingly

Write a program to crypt its input according to a specified transformation scheme

  If a class is derived protected

If a class is derived protected from a base class, explain how this affects the inheritance of all public, protected, and private members of the base class by the derived class.

  Design a nested program

How many levels of nesting are there in this design?

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