Question

Create a C++ program to : Prompt user for seven test score Store the scores into...

Create a C++ program to :

  1. Prompt user for seven test score
  2. Store the scores into an array
  3. Print the array before and after sorting
  4. Print the test average
  5. Convert the average to letter grade
  6. Search for a test score 90, using linear search
    1. Print, if test score 90 was found and at what position
  7. Add Comments

SEPARATE THE FILES INTO 3 : header.h, functions.cpp, main.cpp

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================

// header.h

#ifndef HEADER_H
#define HEADER_H

class Test
{
public:
void readScores();
void printScores();
void sort();
double calcaAvg();
char findGradeLetter(double avg);
int search(int score);
private:
// Declaring variables
static int SIZE;
int scores[7];
};
#endif

============================

// functions.cpp

#include <iostream>
using namespace std;
#include "header.h"


int Test::SIZE=7;

void Test::readScores()
{
for(int i=0;i<SIZE;i++)
{
cout<<"Enter Score in Test#"<<(i+1)<<":";
cin>>scores[i];
}
}
void Test::printScores()
{
for(int i=0;i<SIZE;i++)
{
cout<<scores[i]<<" ";
}
cout<<endl;
}
void Test::sort()
{
//This Logic will Sort the Array of elements in Ascending order
   int temp;
   for (int i = 0; i < SIZE; i++)
{
for (int j = i + 1; j < SIZE; j++)
{
if (scores[i] > scores[j])
{
temp = scores[i];
scores[i] = scores[j];
scores[j] = temp;
}
}
}
}
double Test::calcaAvg()
{
double sum=0;
for(int i=0;i<SIZE;i++)
{
sum+=scores[i];
}
return ((double)sum)/SIZE;
}
char Test::findGradeLetter(double average)
{
char gradeLetter;

   if (average >= 90 && average<=100)
gradeLetter = 'A';
else if (average >= 80 && average < 90)
gradeLetter = 'B';
else if (average >= 70 && average < 80)
gradeLetter = 'C';
else if (average >= 60 && average < 70)
gradeLetter = 'D';
else if (average < 60)
gradeLetter = 'F';
return gradeLetter;
}
int Test::search(int score)
{

for(int i=0;i<SIZE;i++)
{
if(scores[i]==score)
{
return i;
}
}
return -1;
}

=================================

// main.cpp

#include <iostream>
using namespace std;
#include "header.h"
int main()
{

Test t;
t.readScores();
cout<<"_____ Displaying test scores ____"<<endl;
t.printScores();
cout<<"_____After Sorting Displaying test scores ____"<<endl;
t.sort();
t.printScores();
double avg=t.calcaAvg();
char gradeLetter=t.findGradeLetter(avg);
cout<<"Grade Letter :"<<gradeLetter<<endl;
int indx=t.search(90);
if(indx!=-1)
{
cout<<"90 is found in the array at position "<<(indx)<<endl;
}
else
{
cout<<"90 is not found in the array"<<endl;
}
return 0;
}

=================================

output:


=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Create a C++ program to : Prompt user for seven test score Store the scores into...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java Main method Your main program will prompt the user for a test name and...

    In Java Main method Your main program will prompt the user for a test name and the number of scores the user will enter. After creating an arraylist to hold the scores, prompt the user for all the scores to hold in the arraylist. After all the scores are entered, then repeat back the score & letter grade. GradeBook Object Create an instance of a GradeBook object and pass the test name and arraylist to set the instance variables. At...

  • in C++ Create a program that will calculate a student’s grade average of 5 test scores...

    in C++ Create a program that will calculate a student’s grade average of 5 test scores and assign a letter grade for a student. The program should use a class to store the student’s data including the student’s name and score on each of 5 tests. The program should include member functions to 1) get the student’s test scores, 2) calculate the average of the test scores, and 3) display the results as follows: Test scores for Mary: 100 90...

  • Write a c++ program which uses a structure having the indicated member names to store the...

    Write a c++ program which uses a structure having the indicated member names to store the following data: Name (student name) IDnum (student ID number) Tests (an array of three test scores) Average (average test score) Grade (course grade) The program will keep a list of three test scores for one student. The program may prompt the user for the name, ID number, and test scores, or these may be assigned within the program. The average test score will be...

  • Write a program that asks the user to enter five test scores. The program should display...

    Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale: Score Letter Grade...

  • 1. Create a program that takes a numerical score and outputs a letter grade. 2. In...

    1. Create a program that takes a numerical score and outputs a letter grade. 2. In this program, create two void functions titled makeScore and theGrade with an int argument. 3. The function makeScore should have a Reference parameter and theGrade should have a Value parameter. Note: Specific numerical scores and letter grades are listed below: 90-100 = Grade A 80-89 = Grade B 70-79 = Grade C 60-69 = Grade D 0-59 = Grade F 4. The function makeScore...

  • Create a C++ program to calculate grades as well as descriptive statistics for a set of...

    Create a C++ program to calculate grades as well as descriptive statistics for a set of test scores. The test scores can be entered via a user prompt or through an external file. For each student, you need to provide a student name (string) and a test score (float). The program will do the followings: Assign a grade (A, B, C, D, or F) based on a student’s test score. Display the grade roster as shown below: Name      Test Score    ...

  • Write a C++ program that lets a maker of chips and salsa keep track of their...

    Write a C++ program that lets a maker of chips and salsa keep track of their sales for five different types of salsa they produce: mild, medium, sweet, hot, and zesty. It should use two parallel five-element arrays: an array of strings that holds the five salsa names and an array of integers that holds the number of jars sold during the past month for each salsa type. The salsa names should be stored using an initialization list at the...

  • c++ Instructions Overview In this programming challenge you will create a program to handle student test...

    c++ Instructions Overview In this programming challenge you will create a program to handle student test scores.  You will have three tasks to complete in this challenge. Instructions Task 1 Write a program that allocates an array large enough to hold 5 student test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the...

  • [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and...

    [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...

  • Consider the following program that reads students’ test scores into an array and prints the contents of the array. You will add more functions to the program. The instructions are given below.

    Consider the following program that reads students’ test scores into an array and prints the contents of the array.   You will add more functions to the program.  The instructions are given below.              For each of the following exercises, write a function and make the appropriate function call in main.Comments are to be added in the program. 1.       Write a void function to find the average test score for each student and store in an array studentAvgs. void AverageScores( const int scores[][MAX_TESTS],                       int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT