Exercise #2:
10 M gals water per day
71-80
81-90
91-100
101-110
111-120
121-130
131-140
10 M gals water per day
71-80
91-100
101-110
111-120
121-130
131-140
The screenshots of code ,output and water.dat file are attached below:
Below is the C++ code for the same. All the parts from a to g are implemented one after another in the C++ program. Data is read from water.dat file.
#include<bits/stdc++.h>
using namespace std;
int main(){
//part a
cout<<" _________"<<endl;
cout<<"| PART a |"<<endl;
cout<<"|_________|"<<endl;
ifstream fin("water.dat");//for reading water.dat
int monthly_water_arr[50];
int num_months=0;
while(!fin.eof())
fin>>monthly_water_arr[num_months++];//reading data into monthly_water_arr
for(int i=0;i<num_months;i++)
cout<<"MONTH "<<i+1<<" : "<<monthly_water_arr[i]<<endl;//outputting monthly_water_arr
cout<<endl<<"============================================================"<<endl<<endl;
//part b
cout<<" _________"<<endl;
cout<<"| PART b |"<<endl;
cout<<"|_________|"<<endl;
for(int i=0;i<num_months;i++)
if(monthly_water_arr[i]>=71 && monthly_water_arr[i]<=80)//checking if value is btw 71-80
cout<<"MONTH "<<i+1<<" : "<<monthly_water_arr[i]<<" (71-80)"<<endl;//if so print the value
cout<<endl<<"============================================================"<<endl<<endl;
//part c
cout<<" _________"<<endl;
cout<<"| PART c |"<<endl;
cout<<"|_________|"<<endl;
int count_0=0;
for(int i=0;i<num_months;i++)
if(monthly_water_arr[i]>=71 && monthly_water_arr[i]<=80)//checking if value is btw 71-80
count_0++;//if so incrementing count_0
cout<<count_0<<" values between 71 and 80 (inclusive)."<<endl;
cout<<endl<<"============================================================"<<endl<<endl;
//part d
cout<<" _________"<<endl;
cout<<"| PART d |"<<endl;
cout<<"|_________|"<<endl;
int count_1=0;
for(int i=0;i<num_months;i++)
if(monthly_water_arr[i]>=81 && monthly_water_arr[i]<=90)//checking if value is btw 81-90
count_1++;//if so incrementing count_1
cout<<count_0<<" values between 71 and 80 (inclusive)."<<endl;
cout<<count_1<<" values between 81 and 90 (inclusive)."<<endl;
cout<<endl<<"============================================================"<<endl<<endl;
//part e & f
cout<<" ___________"<<endl;
cout<<"| PART e-f |"<<endl;
cout<<"|___________|"<<endl;
int count_arr[7]={0};
for(int i=0;i<num_months;i++)
//using if-else statements to put count in count_arr
if(monthly_water_arr[i]>=71 && monthly_water_arr[i]<=80)
count_arr[0]++;
else if(monthly_water_arr[i]>=81 && monthly_water_arr[i]<=90)
count_arr[1]++;
else if(monthly_water_arr[i]>=91 && monthly_water_arr[i]<=100)
count_arr[2]++;
else if(monthly_water_arr[i]>=101 && monthly_water_arr[i]<=110)
count_arr[3]++;
else if(monthly_water_arr[i]>=111 && monthly_water_arr[i]<=120)
count_arr[4]++;
else if(monthly_water_arr[i]>=121 && monthly_water_arr[i]<=130)
count_arr[5]++;
else if(monthly_water_arr[i]>=131 && monthly_water_arr[i]<=140)
count_arr[6]++;
for(int i=0;i<7;i++)
cout<<(7+i)*10+1<<"-"<<(8+i)*10<<" : "<<count_arr[i]<<endl;//using i to generate labels
cout<<endl<<"============================================================"<<endl<<endl;
//part g
cout<<" _________"<<endl;
cout<<"| PART g |"<<endl;
cout<<"|_________|"<<endl;
for(int i=0;i<7;i++)
if(count_arr[i]!=0)
cout<<(7+i)*10+1<<"-"<<(8+i)*10<<" : "<<count_arr[i]<<endl;//outputting only non-zero lines
cout<<endl<<"============================================================"<<endl<<endl;
}
Exercise #2: 10 M gals water per day 71-80 81-90 91-100 101-110 111-120 121-130 131-140 10...
Exercise #2:Create a data file named water.dat with the following data: 123 134 122 128 111 110 98 99 78 98 100 120 122 110 111 123 134 122 128 111 110 98 99 78 98 100 120 122 110 111. Each number represents the number of millions of gallons of water provided to a major city over the period of one month. The data runs for quite a number of months. You will write a loop to read all the data...
Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...
Copy the following java codes and compile //// HighArray.java //// HighArrayApp.java Study carefully the design and implementation HighArray class and note the attributes and its methods. Create findAll method which uses linear search algorithm to return all number of occurrences of specified element. /** * find an element from array and returns all number of occurrences of the specified element, returns 0 if the element does not exit. * * @param foundElement Element to be found */ int findAll(int...
a. Find the FV of $1,000 invested to earn 10% annually 5 years from now. Answer this question by using a math formula and also by using the Excel function wizard. Inputs: PV = 1000 I/YR = 10% N = 5 Formula: FV = PV(1+I)^N = Wizard (FV): $1,610.51 Note: When you use the wizard and fill in the menu items, the result is the formula you see on the formula line if you click on cell E12. Put the...
so i have my c++ code and ive been working on this for hours but i cant get it to run im not allowed to use arrays. im not sure how to fix it thank you for the help our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses...
okay so here is my c++ code and the errors im really stuck on fixing what i did wrong it seems to be the same repeated error our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses A your program should use a loop and your morse code printing...
PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create the schema, and package. 2. Create users x1 and x2 who are the participants in the auction. They will need acces to the package. 3. Bid on the same item and record your observations. Verify all scenarios. Upload the files with the missing code and a detailed sample run. AUCTION OWNER.TXT SQL> conn / as sysdba Connected. SQL> drop user xyz cascade; User dropped....
69. THE ENDOSPORE itself is might to stain_?_ color in an ACID FAST stain. (a) HOT pink (c) purple (d) green (e) baby-blue 70. All STAINS begin with a properly prepared _?_ . (a) dye (b) slide (c) smear (d) dog (e) cat 71. Which of the following is an ENDOTOXIN found in some microbes? This is results in fever, blood vessel dilation and possibly SHOCK when it is released into the human blood stream? (a) the plasma membrane (b)...
Python Pandas, Series and DataFrame Question (NO Loops, No If Statements, No List Comprehensions) The file bank.csv contains data about bank customers. The last column ('Personal Loan') indicates whether or not the customer was approved for a personal loan or not. Write a function named loan_by_zip that accepts 3 parameters: a file name, a minimum number of records, and a percentage approval rate. The function should return a DataFrame of those zip codes for which we meet the minimum number...
CASE 1-5 Financial Statement Ratio Computation Refer to Campbell Soup Company's financial Campbell Soup statements in Appendix A. Required: Compute the following ratios for Year 11. Liquidity ratios: Asset utilization ratios:* a. Current ratio n. Cash turnover b. Acid-test ratio 0. Accounts receivable turnover c. Days to sell inventory p. Inventory turnover d. Collection period 4. Working capital turnover Capital structure and solvency ratios: 1. Fixed assets turnover e. Total debt to total equity s. Total assets turnover f. Long-term...