This problem is for chapter 3 Write a C++ program that calculates the average ra
ID: 3620649 • Letter: T
Question
This problem is for chapter 3Write a C++ program that calculates the average rainfall for three months. Enter the name of the month and the rainfall(in inches) for that month. Express all output numerical values with one decimal place. Name this program: project3.cpp The name and path of the are entered from the key board. This is notepad file that the program will use The name of this file is in3.txt (Name tins output file out3.txt) COMPUTE THE AVERAOK RAINFALL FOR A THREE MONTH PERIOD The average rainfall for June. July, and August is 4.0 inches. Programmer insert your name here
Explanation / Answer
#include #include #include using namespace std; void main() { //Main function double num,sum=0.0; ifstream infile; fstream dataFile; string month; //for opening a file infile.open("in3.txt"); //Logic while(infile) { infile>>num; sum=sum+num; cout>month; } double avg=sum/3; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.