In: Economics
Write a test program that prompts the user to enter 10 numbers and displays the mean and deviation, as shown in the following sample run:
Your program should contain the following functions:
// Compute the mean of an array of double values double mean(const double x[], int size) // Compute the deviation of double values double deviation(const double x[], int size)
Write a test program that prompts the user to enter 10 numbers and displays the mean and deviation, as shown in the following sample run:
ex:
Enter ten numbers: 1.9 2.5 3.7 2 1 6 3 4 5 2
The mean is 3.11
The standard deviation is 1.55738
So this what I have:
#include <iostream>
#include <cmath>
using namespace std;
void displayVals(int vals[], int numVals, int sum);
void getVals(int vals[], int numVals);
double average(int sum, int numVals);
double stanDev(int vals[], double mean, int numVals);
int main()
{
int numVals=10;
int sum = 0;
int vals[9];
getVals(vals, numVals);
cout << endl;
displayVals(vals, numVals, sum);
cout << endl;
}
void getVals(int vals[], int numVals)
{
int index;
cout << "Enter ten numbers :" <<
"\n";
for (index = 0; index < numVals; index++) {
cout << index + 1;
cin >> vals[index];
}
}
void displayVals(int vals[], int numVals, int sum)
{
int index;
for (index = 0; index < numVals; index++) {
cout << index + 1;
cout << vals[index] <<
".\n";
}
cout << endl;
cout << "The mean is ";
cout << average(vals, numVals, sum) <<
".\n";
cout << endl;
cout << "The standard deviation is: ";
cout << stanDev(vals, numVals, sum) <<
".\n";
}
double average(int sum, int numVals)
{
double dsum = (double)sum;
double dnumVals = (double)numVals;
return dsum / dnumVals;
}
double stanDev(int vals[], double mean, int numVals)
{
double sum = 0, dVals = 0, value = 0, variance =
0;
for (int i = 0; i < numVals; i++)
{
dVals = (double)vals[i];
value = (dVals - mean)*(dVals -
mean);
sum += value;
variance = sum / (numVals);
}
return sqrt(variance);
}
In: Computer Science
What is the difference between a tit-for-tat strategy and a trigger strategy?
In: Economics
What type of gametes can be produced by simple non-disjunction of the sex chromosomes in a human male? Simple non-disjunction means that non-disjunction occurs in meiosis I or meiosis II, but not in both meiosis I and meiosis II. Choose all answers that are correct.
In: Biology
Alpha company produces two products, X and Y, that are sold to retailers. The budgeted sales volumes for the next quarter are as follows: Product Unit X 32000 Y 56000 The inventory of finished goods is budgeted to increase by 1000 units of X and decrease by 2000 units of Y by the end of that quarter. Materials A and B are used in production of both products. The quantities required of each material to produce one unit of the finished product and the purchase prices are shown in the table below: A B X 8kg 4kg Y 4kg 3kg Purchase price per kg $1.25 $1.80 Budgeted Opening Inventory 30000kg 20000kg The company plans to hold inventory of raw materials at the end of the quarter equal to 5% of the quarter's material usage budget. Required: A) Prepare the following budgets for the quarter: i) the production budget in units ii) the material usage budget (in kg) iii) the material purchases budget (in kg and $) B) What is the Master Budget and why is it useful?
In: Accounting
1.List two to three things you wonder about that might be answered in this class. Examples: How does a water wave become a Tsunami? Why do I get “bounced” when my car goes over a big bump?
2. Identify a real world oscillating object. Include a photograph or sketch of the object.
In: Physics
managerial accounting
main topics from this course: Budgeting,Overhead and Marketing Variances,- Absorption Costs Systems and Cost Allocation
How does the information presented in this course compare with your life experiences and career goals?
What is the most significant concept from this course that you will carry with you as you continue your educational journey?
In: Accounting
The equilibrium constant, K, for the following reaction is 7.00×10-5 at 673 K.
NH4I(s) <----> NH3(g) + HI(g)
An equilibrium mixture of the solid and the two gases in a 1.00 L flask at 673 K contains 0.308 mol NH4I, 8.37×10-3 M NH3 and 8.37×10-3 M HI. If the concentration of NH3(g) is suddenly increased to 1.50×10-2 M, what will be the concentrations of the two gases once equilibrium has been reestablished?
[NH3]=
[HI]=
In: Chemistry
***Please discuss in detail, the difference between the two medications Cimetidine and omeprazole and how they work in the digestive system with regards to controlling GERD**
In: Anatomy and Physiology
1. Why librarians need to be familiar with online
databases
2. What is online database?
3. overview of those two databases (jstor and project MUSE)
4. List of journals under their domains
5. Functionalities of each database
6. Layout and
structural usability of each database
Comparison between those two databases (if any)
In: Computer Science
I WANT THIS CODE TO BE SIMPLE BECAUSE I AM NEW TO CODING AND I WANT TO KNOW THE DETAILS! straight C
Write a quiz program that helps a student learn the multiplication operation. A series of questions are asked, such as: What is 12 mod 5?Note: the numbers 12 and 5 were randomly generated by your program. After the user types in their answer, print a suitable message to the screen. The game ends after 4 wrong answers.
In: Computer Science
Develop the 8-point Discrete Fourier Transform (DFT) using butterfly diagrams for the discrete input sequence x(n) = {1, 2, 3, 4, 4, 3, 2, 1} using radix-2 Decimation in Frequency - Fast Fourier Transform (DIF-FFT) algorithm.
In: Computer Science
Derive the equations of the electron and hole concentrations in terms of the impurity doping concentrations, using the concepts of complete ionization and charge neutrality.
In: Physics
Can someone add comments on this explaining the code and also I could not figure out how to code the finalbattle to make it where if u use a lowercase "a" for the final attack you lose.
from sys import exit
print ("The city needs your help, you must save them!")
print ("What is your name?")
name=input("Enter your name:")
print ("Ok, are you ready to begin?")
def decisions():
decision = input("yes or no?\n")
if decision == "yes":
print ("You made the right decision, may your blade keep you
safe.")
elif decision == "no":
print ("You have let the people down and the city will be
destroyed.")
exit(0)
decisions()
def choosepath():
print ("You must leave the town in order to save the
people.")
print ("You may go either north or south to destroy the enemies
raiding the city.")
print ("The paths to the east and west have been destroyed and it
is up to you to stop this from happening elsewhere.")
path = ''
while path !='north' and path !='south'and path !='east' and path
!='west':
print ("which path would you like to take?")
print ("choose north or south:")
path = input()
if path =="north":
print ("You head north towards the enemy approching the front
gates.")
elif path=="south":
print ("You head south to sneak up on the enemy and attack from
behind.")
choosepath()
print("You arrive at the battle and start planning your
attack!")
print("You spot an enemy and must make a wise decision to start
your fight...")
print("Before picking your target you must choose your
weapon!")
def weapon():
weapon = ''
while weapon != 'sword' and weapon !='axe':
print("Choose your sword or axe!")
weapon = input ()
if weapon == "sword":
print("You chose sword!")
elif weapon =="axe":
print ("You chose axe!")
weapon()
print("Now that you have chosen your weapon it is time to
attack!")
print("You look around for a brief moment...")
print("You start to have doubts, now is your chance to turn
around.")
print("Would you like to turn around and let the people die to save
your own life?")
final_decision = input ("yes or no?\n")
if final_decision == "yes":
print("You have let the people down...")
exit(0)
elif final_decision =="no":
print("You are a brave knight.")
print("Now is your time to strike!")
print("Quickly! the enemy is approaching, it is now or never!")
enemy = 0
a=50
A=50
enemy_approaches = input ("Press a to attack!")
if enemy_approaches=='a' or enemy_approaches =='A':
enemy = enemy + 50
enemy_approaches = input ("The enemy is getting weaker keep
attacking!")
if enemy_approaches=='a' or enemy_approaches =='A':
enemy = enemy + 50
enemy_approaches = input ("Time for the final blow!")
if enemy_approaches=='a' or enemy_approaches =='A':
enemy = enemy+ 50
if enemy >= 150:
print ("Congratulations, you have defeated the enemy!")
def finalbattle():
print("You defeated a soldier now it is time to take out the
leader!")
print("You must be careful great knight, he if very
powerful!")
print("You will need to use power attacks to defeat him!")
print("Use capital A for a power attack.")
print("Use basic attacks until he is stunned, when the time is
right kill him with a powerful blow!")
print("...")
print("NOW! IT IS TIME TO ATTACK!")
finalbattle()
enemy = 0
a=50
A=100
enemy_approaches = input ("Press a to attack!")
if enemy_approaches=='a':
enemy = enemy + 50
enemy_approaches = input ("One more and you will have him
stunned!")
if enemy_approaches=='a':
enemy = enemy + 50
enemy_approaches = input ("You stunned him! Use your powerful
strike")
if enemy_approaches =='A':
enemy = enemy+ 100
if enemy >= 200:
print("You have defeated the boss and saved the city!")
print("YOU WIN!")
In: Computer Science
assuming 80 mg of vitamin C present in 29.57 ml of the orange juice, how many millileters of 0.0102 M KIO3 would be required to reach the stoichiometric point? i dont want just an answer, i want to know how to do it too. thanks!
In: Chemistry