Question

Write a program that uses pointer notation to dynamically allocate parallel array(s) large enough to hold...

Write a program that uses pointer notation to dynamically allocate parallel array(s) large enough to hold a user-defined number of test scores and student names, using parallel arrays.

After student names and corresponding scores are entered, the array(s) should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score for the group (do not include the lowest score in the calculation of average grade). The program should display the sorted list of scores and student names, as well as the course’s average (use appropriate headings.)

Sample input data

Sample output

Jon Apple, 90

Jane Doe, 85

Bob Smith, 91

Tom Jones, 59

Susan Price, 70

Average: 84.5

Grade Student         

91 Bob Smith

90       Jon Apple

85 Jane Doe

70 Susan Price

59 Tom Jones

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

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

#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

   int main()
   {
       //Declaring variables
int size;
string line;
  
//Getting the input entered by the user
cout<<"Enter size:";
cin>>size;
  
// Creating array dynamically
string *names=new string[size];
int *scores=new int[size];
  
cin.ignore();
  
//Getting the input entered by the user
for(int i=0;i<size;i++)
{
   getline(cin,line);
   int pos=line.find(", ");
   *(names+i)=line.substr(0,pos);
   *(scores+i)=atoi(line.substr(pos+1,line.length()).c_str());
  
       }
       //Finding the minimum score
       int min=*(scores+0);
       for(int i=0;i<size;i++)
       {
           if(min>(*(scores+i)))
           min=*(scores+i);
       }
      
       double sum=0,average;
       for(int i=0;i<size;i++)
       {
           if(*(scores+i)!=min)
           {
               sum+=*(scores+i);
           }
       }
       average=(double)sum/(size-1);
       cout<<"Average :"<<average<<endl;
      
           /* This Logic will Sort the Array
           * of elements in decending order
           */
   int temp;
   string tname;
   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;
  
tname = *(names+i);
*(names+i) = *(names+j);
*(names+j) = tname;
  
  
  
}
}
}
  
cout<<"\nGrade\tStudent"<<endl;
for(int i=0;i<size;i++)
{
   cout<<*(scores+i)<<"\t"<<*(names+i)<<endl;
       }
       return 0;
      
   }

____________________________

Output:


_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Write a program that uses pointer notation to dynamically allocate parallel array(s) large enough to hold...
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
  • Write a program that dynamically allocates an array in the freestore large enough to hold a...

    Write a program that dynamically allocates an array in the freestore large enough to hold a user defined number of test scores as doubles. Once all the scores are entered, the array should be passed to a function that finds the highest score. Another function the array should be passed to a function that finds the lowest score. Another function should be called that calculates the average score. The program should show the highest, lowest and average scores. Must use...

  • Write a program that dynamically allocates an array in the freestore large enough to hold a...

    Write a program that dynamically allocates an array in the freestore large enough to hold a user defined number of test scores as doubles. Once all the scores are entered, the array should be passed to a function that finds the highest score. Another function the array should be passed to a function that finds the lowest score. Another function should be called that calculates the average score. The program should show the highest, lowest and average scores. Must use...

  • Student average array program

    Having a bit of trouble in my c++ class, was wondering if anyone can help.Write a program to calculate students' average test scores and their grades. You may assume the following input data:Johnson 85 83 77 91 76Aniston 80 90 95 93 48Cooper 78 81 11 90 73Gupta 92 83 30 68 87Blair 23 45 96 38 59Clark 60 85 45 39 67Kennedy 77 31 52 74 83Bronson 93 94 89 77 97Sunny 79 85 28 93 82Smith 85 72...

  • 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 to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Use your knowledge of algorithm development to create a program using RAPTOR to solve the problem...

    Use your knowledge of algorithm development to create a program using RAPTOR to solve the problem below. Input a list of student names (in to array student[]) and testing scores stored in parallel arrays. Each student have 3 testing scores ranging from 0 to 100 (store into parallel array score1[], score2[], score3[]). Output average score for each student and print out what is his final grade. If average score <60, got F grade. If 60<=average score<70, got D grade. If...

  • Write a program that dynamically allocates an integer array of size of 20 to hold a...

    Write a program that dynamically allocates an integer array of size of 20 to hold a user-defined number of test scores. Once all the scores are entered, the array should be passed to • a function that calculates the average score, the minimal score, and the maximal score in the array, and returns these scores to the main function (hint: use pass by reference, I gave an example in the class) • a function that searches a specific number. The...

  • read it carefully C++ Question: Write a program that dynamically allocates an array large enough to...

    read it carefully C++ Question: Write a program that dynamically allocates an array large enough to hold a user-defined number of 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 sorted list of scores and averages with appropriate headings. Use pointer notation rather than array notation whenever possible. Input Validation: Do not...

  • C++: Create a grade book program that includes a class of up to 20 students each...

    C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...

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