Write a C++ program that inputs a sequence of integers into a vector, computes the average, and then outputs the # of input values, the average, and the values themselves. There are 0 or more inputs values, followed by a negative value as the sentinel; the negative value is not stored and not counted. The following sample input:
10 20 0 99 -1
would produce the following output:
N: 4 Avg: 32.25 10 20 0 99
The main program has been written for you, your job is to implement the two functions InputData and GetAverage. See the comments in the "student.cpp" file for specific implementation details.
main.cpp
#include <iostream>
#include <vector>
using namespace std;
// functions from student.cpp:
int InputData(vector<int>& V);
double GetAverage(vector<int> V, int N);
int main()
{
// assume at most 100 inputs:
vector<int> inputs(100);
int N;
double avg;
N = InputData(inputs);
avg = GetAverage(inputs, N);
cout << "N: " << N << endl;
cout << "Avg: " << avg << endl;
for (int i = 0; i < N; ++i)
{
cout << inputs.at(i) << endl;
}
return 0;
}
student.cpp
int InputData(vector<int>& V)
{
// TODO
return 0;
}
//
// GetAverage
//
// Returns the average of the first N values in the vector; if N is
0 then
// 0.0 is returned.
//
double GetAverage(vector<int> V, int N)
{
// TODO
return 0.0;
}
In: Computer Science
Consider a concentration cell. Two Ag-electrodes are immersed in
AgNO3 solutions of different concentrations. When the two
compartments have an AgNO3-concentration of 1 M and 0.1 M,
respectively, the measured voltage is 0.065 V (note: T in not
necessarily = 25°C !).
a. What is the voltage, if the two compartments have AgNO3-concentration of 1 M and 0.01 M, respectively?
The electrochemical behavior of silver nanoclusters (Agn, with n
the number of Ag atoms in the cluster) is investigated using the
following electrochemical cells at 298 K:
I. Ag(s) | AgCl (saturated) || Ag+(aq, 0.01M) |
Ag(s), E=0.170
II. (Pt electrode) Agn (s, nanocluster) | Ag+(aq,
0.01M) || AgCl (saturated) | Ag(s), with E = +1.030 V for
Ag5 nanocluster and E = +0.430 V for Ag10 nanocluster
The standard reduction potential for Ag+ + e- → Ag, is E0 = +0.800 V.
b. Use this data to calculate the solubility product of AgCl.
The two nanoclusters Ag5 and Ag10-nanoclusters have standard potentials different from the potential of metallic bulk silver.
c. Calculate the standard potentials of Ag5 and of Ag10 nanoclusters. [for this part use Ksp(AgCl)=1.800·10-5; this is not the same value as calculated in b.]
d. What happens, if you put the Ag10 nanoclusters and – in a second experiment – the Ag5 nanoclusters into an aqueous solution of pH=5? Estimate the consequences using the reduction potentials you calculated.
In: Chemistry
Create a new Python program (you choose the filename) that contains a main function and another function named change_list. Refer to the SAMPLE OUTPUT after reading the following requirements.
In the main function:
In the change_list function:
Back in the main function:
SAMPLE OUTPUT
Here is the list of random integers...
99 66 57 81 75 59 58 74 56 90 75 65
The 4th element in the list is 81
The element at index 9 is 90
The smallest element in the list is 56
The size of the list is now 6
change_list returned this sorted list...
56 58 59 74 75 81
In: Computer Science
Assume the population mean IQ is 100 with a standard deviation of 15. A sample of 25 students recently took an IQ test in which their average score was 108. If another sample of 25 students was selected, what is the probability that that sample would have a mean greater than 108?
In: Statistics and Probability
Show the effect of each of the following events on the market for labor in the computer
manufacturing industry.
a. Congress buys personal computers for all U.S. college students
b. More college students major in engineering and computer science
c. Computer firms build new manufacturing plants
In: Economics
In: Statistics and Probability
The Mathematics test scores for BEKM students were analyzed and stored in a file. Assuming the scores are normally distributed. Knowing that 20% of the mean scores were above 70 and 15% of the mean scores were below 40, find their mean and standard deviation of the test scores for the students
In: Statistics and Probability
Suppose that distribution of the mid-term grades of the entire classes in the College follows N(78,36).
(a) What is the proportion of students who received the grades less than 75?
(b) Suppose that there is a class with 50 students. What is the probability that the average grades of this class is less than 75?
In: Statistics and Probability
According to the national center of education statistics, 67% of Texas students are eligible to receive free or reduced-price lunches. Suppose you randomly choose 310 Texas Students. Find the probability that no more than 73% of them are eligible to receive free or reduced-price lunches.
In: Statistics and Probability
According to the National Center for Education Statistics, 69% of Texas students are eligible to receive free or reduced-price lunches. Suppose you randomly choose 285 Texas students. Find the probability that no more than 73% of them are eligible to receive free or reduced-price lunches.
In: Math