Question & Answer: 1) Create a txt file named "hwIdata.txt" that contains 30 students test scores in the range 0-100. Assume test scores are integers……

Hello, I am currently taking a computer programming class in C++. I was given this assignment to complete that focuses on Arrays. I understand how to do all the parts from 1 to 7. But when I get to part 8 I’m not sure of how to go by completeing it. Can someone please help. Thank you

1) Create a txt file named hwIdata.txt that contains 30 students test scores in the range 0-100. Assume test scores are integers. You can use the following sample data: 76 84 75 62 58 75 93 54 36 87 81 88 68 90 73 80 74 84 96 100 61 5084 47 92 87 76 87 82 64 2) Read 30 test scores from the file hwIdata.txt and store them in a one-dimensional array 3) Write a function printList that prints the content of an array on the screen. The function has two formal parameters: an int array and an int variable containing the size of the array. 4) Write a function getLargest that finds and returns the largest value (first occurrence if more than one) in an array 5) Write a function getSmallest that finds and returns the smallest value (first occurrence if more than one) in an array 6) Write a function getAverage that finds and returns the average value of an array. The average value should be of type double. 7) In the function main, call the above functions to output all the test scores stored in the array, as well as the highest, the lowest, and the average test score. 8) In the function main, write statements to find the number of scores in each of the following ranges: 1) 0-50 (0score < 50) 2) 50-55 150 score <55) 3) 55-60 4) 60-65 5) 65-70 6) 70-75 7) 75-80 8) 80-85 9) 85-90 10) 90-100 (90score -100 Notice that 100 is included in this range Output the score ranges and the number of scores in each range. If you run your program with the above sample data, you should have results same as follows: Number of Scores Range 0 SO 50 55 55- 60 60-65 65-70 70-75 75-80 80-85 5-90 90 100

1) Create a txt file named “hwIdata.txt” that contains 30 students test scores in the range 0-100. Assume test scores are integers. You can use the following sample data: 76 84 75 62 58 75 93 54 36 87 81 88 68 90 73 80 74 84 96 100 61 5084 47 92 87 76 87 82 64 2) Read 30 test scores from the file “hwIdata.txt” and store them in a one-dimensional array 3) Write a function printList that prints the content of an array on the screen. The function has two formal parameters: an int array and an int variable containing the size of the array. 4) Write a function getLargest that finds and returns the largest value (first occurrence if more than one) in an array 5) Write a function getSmallest that finds and returns the smallest value (first occurrence if more than one) in an array 6) Write a function getAverage that finds and returns the average value of an array. The average value should be of type double. 7) In the function main, call the above functions to output all the test scores stored in the array, as well as the highest, the lowest, and the average test score. 8) In the function main, write statements to find the number of scores in each of the following ranges: 1) 0-50 (0score

Expert Answer

 

Copyable Code:

#include <iostream>

#include<stdio.h>

#include<fstream>

#include<string>

using namespace std;

void printList(int a[],int size)

{

int i;

cout<<“nContent of the array is:”;

for(i=0;i<30;i++)

{

cout<<a[i]<<“t”;

}

}

int getLargest(int a[],int size)

{

int largest,i;

largest=a[0];

for(i=0;i<size;i++)

{

if(largest<a[i])

{

largest=a[i];

}

}

return largest;

}

int getSmallest(int a[],int size)

{

int smallest,i;

smallest=a[0];

for(i=0;i<size;i++)

{

if(smallest>a[i])

{

smallest=a[i];

}

}

return smallest;

}

double getAverage(int a[],int size)

{

double avergae;

int tot=0,i;

for(i=0;i<size;i++)

{

tot=tot+a[i];

}

avergae=tot/size;

return avergae;

}

//main

void main()

{

ifstream infile(“hw1data.txt”);

int arr[30],i,count=0;

int large,small;

double aver;

for(i=0;i<30;i++)

{

infile>>arr[i];

}

printList(arr,30);

large=getLargest(arr,30);

cout<<“nnLargest:”<<large;

small=getSmallest(arr,30);

cout<<“nnSmallest:”<<small;

aver=getAverage(arr,30);

cout<<“nnAverage:”<<aver;

cout<<“nn Range”<<“tt Number of Scores”;

for(i=0;i<30;i++)

{

if(arr[i]<50)

{

count++;

}

}

cout<<“n0..50″<<“ttt”<<count;

count=0;

for(i=0;i<30;i++)

{

if(arr[i]<55 && arr[i]>=50)

{

count++;

}

}

cout<<“n50..55″<<“ttt”<<count;

count=0;

for(i=0;i<30;i++)

{

if(arr[i]<60 && arr[i]>=55)

{

count++;

}

}

cout<<“n55..60″<<“ttt”<<count;

count=0;

for(i=0;i<30;i++)

{

if(arr[i]<65 && arr[i]>=60)

{

count++;

}

}

cout<<“n60..65″<<“ttt”<<count;

count=0;

for(i=0;i<30;i++)

{

if(arr[i]<70 && arr[i]>=65)

{

count++;

}

}

cout<<“n65..70″<<“ttt”<<count;

count=0;

for(i=0;i<30;i++)

{

if(arr[i]<75 && arr[i]>=70)

{

count++;

}

}

cout<<“n70..75″<<“ttt”<<count;

count=0;

for(i=0;i<30;i++)

{

if(arr[i]<80 && arr[i]>=75)

{

count++;

}

}

cout<<“n75..80″<<“ttt”<<count;

count=0;

for(i=0;i<30;i++)

{

if(arr[i]<85 && arr[i]>=80)

{

count++;

}

}

cout<<“n80..85″<<“ttt”<<count;

count=0;

for(i=0;i<30;i++)

{

if(arr[i]<90 && arr[i]>=85)

{

count++;

}

}

cout<<“n85..90″<<“ttt”<<count;

count=0;

for(i=0;i<30;i++)

{

if(arr[i]<=100 && arr[i]>=90)

{

count++;

}

}

cout<<“n90..100″<<“ttt”<<count;

cout<<“n”;

}

Still stressed from student homework?
Get quality assistance from academic writers!