Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, below are 5 pictures that detail a lab I need to ahve done. Our labs prep

ID: 3585190 • Letter: H

Question

Hello, below are 5 pictures that detail a lab I need to ahve done. Our labs prep us for our 4 major projects we do so they are open book/open to get help with. The 5 pictures show what needs to be done. It is very important the Lab is done exactly like it asks or the grader will not accept it. Not very long but as a new coder I am not that good and would appreicate help. Please post your code and helpful comments throughout it will really help me so I can follow and understand it better.

For this lab we are working on writing functions. This lab will have 2 parts. For full credit, you must turn in both parts. Details Part 1 For this part you will write 4 functions that adhere to a given signature. Normally I don't make you write more than the single function I'll connect to for testing but for this week, I need to make sure you can write functions so I'm going to be testing them independently of the rest of the code in part 1. The 4 functions are listed below and must have the same signatures: double stdDev( int x1, int x2, int x3, int x4 ); double mean( int x1, int x2, int x3, int x4); double double sumofSquares( double d1, double d2, double d3, double d4 ); variance( int x1, int x2, int x3, int x4 ); You must use the same spelling, return type, and parameter list. They must also be declared in the header file for this week's lab. See the requirements below. Then in the cpp file, you will implement each of these functions. You may notice that some of these functions can be used from the other functions. For example, to compute variance you need the mean you have to get a sum of squares. You should use this to your advantage so you aren't reimplementing code that you've written functions for

Explanation / Answer

//File Name: lab6.h
#ifndef lab6_H
#define lab6_H
//To calculate and return standard deviation
double stdDev(int x1, int x2, int x3, int x4);
//To calculate and return mean
double mean(int x1, int x2, int x3, int x4);
//To calculate and return variance
double variance(int x1, int x2, int x3, int x4);
//To calculate and return sum of the square
double sumOfSquare(double d1, double d2, double d3, double d4);

#endif

//File Name: lab6.cpp
#include"lab6.h"
#include<iostream>
#include<math.h>
using namespace std;

//To calculate and return mean
double mean(int x1, int x2, int x3, int x4)
{
//To store the result
double sum = 0;
//Calculates the sum
sum += x1 + x2 + x3 + x4;
//Calculate average and returns it
return (sum / 4);
}//End of function

//To calculate and return variance
double variance(int x1, int x2, int x3, int x4)
{
//To store the variance result
double res = 0;
//Calculates the number minus mean of the numbers
double - mean(x1, x2, x3, x4);
double two = x2 - mean(x1, x2, x3, x4);
double three = x3 - mean(x1, x2, x3, x4);
double four = x4 - mean(x1, x2, x3, x4);
//Calls the sumOfSquare
res += sumOfSquare(one, two, three, four);
//Returns the result after calculating the average
return res/4;
}//End of function

//To calculate and return sum of the square
double sumOfSquare(double d1, double d2, double d3, double d4)
{
//To store the sum
double sum = 0;
//Calculates the sum of the square of the numbers
sum = (d1 * d1) + (d2 * d2) + (d3 * d3) + (d4 * d4);
//Returns the result
return sum;
}//End of function

//To calculate and return standard deviation
double stdDev(int x1, int x2, int x3, int x4)
{
//To store the result
double res = 0;
//Calls the variance function to calculate variance and find it square root
res = sqrt(variance(x1, x2, x3, x4));
//Returns the result
return res;
}//End of function

//Main function definition
int main()
{
//Displays the result
cout<<" Sum of the Square : "<<sumOfSquare(1, 2, 3, 4);
cout<<" Mean : "<<mean(1, 2, 3, 4);
cout<<" Variance : "<<variance(1, 2, 3, 4);
cout<<" Standard deviation: "<<stdDev(1, 2, 3, 4);
}//End of function

Sample Run:

Sum of the Square : 30
Mean : 2.5
Variance : 1.25
Standard deviation: 1.11803

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote