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 program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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