Sunday, December 8, 2019

Mean, Mode and Median Checker in C++

A program that will ask the user how many items to be processed and the program will ask the user to give a series of integer values and then the program will check and determine which of the given number in a mean, mode and median using C++ programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My Facebook address is https://www.facebook.com/profile.php?...

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/

https://www.unlimitedbooksph.com/

Thank you very much for your help and support.




Sample Program Output


Program Listing

#include <iostream>

using namespace std;

int main()
{
int array[50],sum=0, n=0,median1=0,median2=0, mode=0,count[50];
int pos1=0,pos2=0;
sum=0;
float mean=0.00;

cout <<"\tMean, Mode and Median Checker in C++";
cout <<"\n\n";
cout<<"\tHow many items? : ";
cin>>n;
cout <<"\n\n";
for(int a=0;a<n;a++)
{
cout<<"\tGive value in item no. "<<a+1 << " : ";
cin>>array[a];
count[a]=0;
}
for(int b=0;b<n;b++)
{
sum=sum+array[b];
}
cout <<"\n";
cout <<"\tDisplay Results";
cout <<"\n\n";
cout<<"\tThe Sum is : "<<sum;
int small,pos,temp;

for(int i=0;i<n-1;i++)
{
small=array[i];
pos=i;
for(int j=i+1;j<n;j++)
{
if(small>array[j])
{
small=array[j];
pos=j;
}
}
temp=array[pos];
array[pos]=array[i];
array[i]=temp;
}
mean=sum/n;
cout <<"\n";
cout<<"\tThe Mean is : "<<mean;
if(n%2!=0)
{
pos1=pos2=(n+1)/2;
}
else
{
pos1=n/2;
pos2=n/2 +1;
}
median1=array[pos1];
median2=array[pos2];
cout <<"\n";
cout<< "\tThe Median is  : "<<median1<<"\t : "<<median2;
for(int c=0;c<n; c++)
{
for(int d=0;d<n;d++)
{
if(array[c]==array[d])
{
count[c]++;
}
}
}
int modepos,max=count[0];
for(int e=1;e<n;e++)
{
if(max<count[e])
{
max=count[e];
modepos=e;
}
}
mode=array[modepos];
cout <<"\n";
cout<<"\tThe Mode is : "<<mode;
cout <<"\n";
cout <<"\tEnd of Program";
cout <<"\n\n";
}


No comments:

Post a Comment