write a C programming that can run like this to find the rainfall data of 6 weeks with the data inported from a text file. do not use array. Notice that it's possible for the result to have two different days or week.
#include<iostream>
#include <iomanip>
using namespace std;
// Constant for the number of months
const int NUM_MONTHS = 12;
// Function prototypes
double getTotal(double [], int);
double getAverage(double [], int);
double getLargest(double [], int, int &);
double getSmallest(double [], int, int &);
double getTotal(int rainFall,double NUM_MONTHS[])
{
double total = 0;
for (int count = 0; count < NUM_MONTH; count++)
total += NUM_MONTH[count];
return total;
}
double getAverage(int rainFall,double NUM_MONTH[])
{getTotal(rainFall,NUM_MONTH)
average= total/NUM_MONTHS;
return average;
}
double getHighest(int rainFall, double NUM_MONTHS[]) //I left out the subScript peice as I was not sure how to procede with that;
{
double largest;
largest = NUM_MONTHS[0];
for ( int month = 1; month <= NUM_MONTHS; month++ ){
if ( values[month] > largest ){
largest = values[month];
return largest;
}
double getSmallest(int rainFall, double NUM_MONTHS[])
046
{
double smallest;
smallest = NUM_MONTHS[0];
for ( int month = 1; month <= NUM_MONTHS; month){
if ( values[month] < smallest ){
smallest = values[month];
return smallest;
}
int main()
{
// Array to hold the rainfall data
double rainFall[NUM_MONTHS];
// Get the rainfall for each month.
or (int month = 0; month < NUM_MONTHS; month++)
// Get this month's rainfall.
cout << "Enter the rainfall (in inches) for month #";
cout << (month + 1) << ": ";
cin >> rainFall[month];
// Validate the value entered.
while (rainFall[month] < 0)
{
cout << "Rainfall must be 0 or more.\n"
<< "Please re-enter: ";
cin >> rainFall[month];
}
}
// Set the numeric output formatting.
cout << fixed << showpoint <<
setprecision(2) << endl;
// Display the total rainfall.
cout << "The total rainfall for the year is ";
cout << getTotal(rainFall, NUM_MONTHS)
<< " inches." << endl;
// Display the average rainfall.
cout << "The average rainfall for the year is ";
cout << getAverage(rainFall, NUM_MONTHS)
<< " inches."
<< endl;
// Now display the largest & smallest amounts.
// The subscript variable will be passed by reference
// the the getLargest and getSmallets functions.
int subScript;
// Display the largest amount of rainfall.
cout << "The largest amount of rainfall was ";
cout << getLargest(rainFall, NUM_MONTHS, subScript)
<< " inches in month ";
cout << (subScript + 1) << "." << endl;
// Display the smallest amount of rainfall.
cout << "The smallest amount of rainfall was ";
cout << getSmallest(rainFall, NUM_MONTHS, subScript)
<< " inches in month ";
cout << (subScript + 1) << "." << endl << endl;
return 0;
}
write a C programming that can run like this to find the rainfall data of 6...
Coding in C++ Write a program using structures to store the following weather information: - Month name - Day of month (Monday, Tuesday, etc) - High Temperature - Low Temperature - Rainfall for the day Use an the input.txt file to load the data into weather structures. Once the data for all the days is entered, the program should calculate and display the: - Total rainfall for the data - Average daily temperatures. (note: you'll need to calculate the days...
Need this program ASAP C++ language 1b. Write the implementation file timeClock.cpp for the class TimeClock. Com pile the file, and save it in the Chap 13 folder of your Student Data Files. 1c. Write a C++ program named weeklyPay.cpp to test your class Timeclock Your program should ask the user how many hours the user worked each day of the week. An object should be created for each day of the week with the number of hours for each...
C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...