Question

In: Computer Science

In C++, please comment on everything as much as posible because i have hard understanding with...

In C++, please comment on everything as much as posible because i have hard understanding with this topic.

DO NOT COPY PAST FROM OTHER POSTS PLEASE

Write a program to do the following.

In the main function, the program should define an integer array and a pointer that points to the array.it will ask the user to input25students’scores (scores are between 0 and 100inclusive, so need to do input validation), then pass the pointer and its size to a function. The function should find the corresponding letter grades and return the pointer that points to the array of letter grades.

Also pass the score pointer and its size to the other function, which will calculate the average of those 25 scores with the lowest and highest score dropped, and then return the average (double type).

The input of those scores and output of the letter scores and average must be in the main function, and there is no input and output in the functions besides the main function.

No global variables are allowed.

90-100 (include 90 and 100) is A

80-90 (include 80 but not include 90) is B

70-80 (include 70 but not include 80) is C

60-70 (include 60 but not include 70) is D

below 60 is F

Solutions

Expert Solution

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

#include<iostream>
using namespace std;

// The function should find the corresponding letter grades
// ghand return the pointer that points to the array of letter grades.
char* letterGrades(int* scores, int size){
  
   char* grades = new char[size];
   for(int i=0; i<size;i++){
       if(scores[i]>=90) grades[i]='A';
       else if(scores[i]>=80) grades[i]='B';
       else if(scores[i]>=70) grades[i]='C';
       else if(scores[i]>=60) grades[i]='D';
       else grades[i]='F';
   }
   return grades;
}

//Also pass the score pointer and its size to the other
// function, which will calculate the average of those 25
// scores with the lowest and highest score dropped,
double getAverage(int *scores, int size){
  
   int min=0, max = 0;
   int total = scores[0];
   for(int i=1; i<size;i++){
       if(scores[i]>scores[max])max =i;
       if(scores[i]<scores[min])min =i;
       total += scores[i];
   }
  
   total = total - scores[min] - scores[max];
   return total/(size-2);
}

int main(){
  
   const int STUDENTS = 25;
   //CREATE array of int and store the address in scores pointer
   int* scores = new int[STUDENTS];
  
   for(int i=0; i<STUDENTS; i++){
       do{
           cout<<"Enter score for student #"<<i+1<<": ";
           cin >> scores[i];
          
       }while(scores[i]<0 || scores[i]>100);
      
   }
  
   char* letter = letterGrades(scores,STUDENTS);
       for(int i=0; i<STUDENTS;i++){
           cout<<scores[i]<<" Grade: " <<letter[i]<<endl;
       }
      
       cout<<"Average after removing max and min scores: "<<getAverage(scores,STUDENTS);


   return 0;
}
==================================================================


Related Solutions

C# programming. Comment/Explain the below code line by line. I am having a hard time following...
C# programming. Comment/Explain the below code line by line. I am having a hard time following it. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Nth_prime {     class Program     {         public static bool isPrime(int number)         {             int counter = 0;             for (int j = 2; j < number; j++)             {                 if (number % j == 0)                 {                     counter = 1;                     break;                 }             }             if (counter == 0)             {                 return true;             }             else             {                 return false;             }         }...
Please - Please have an original assignment not copied because I have to submit to a...
Please - Please have an original assignment not copied because I have to submit to a citing program. The purpose of this assignment is to review the current state of development for your state's health information exchange (HIE) and current participation rate. Compare your state (New Jersey) to three states with similar demographics. Write a 1,000-1,250 word summary related to the ability of your state's HIE to share data and improve the following: Coordination of care Public health initiatives Evidence-based...
Hello, I'm having a hard time solving these problems because I have no idea on what...
Hello, I'm having a hard time solving these problems because I have no idea on what to do with accrued interest. Help is highly appreciated! On March 1, 2015, Bowan Corporation issued 6% bonds dated February 1, 2015, the face amount of $700,000. The bonds were sold for the present value of the bonds on March 1, 2015 plus one-month accrued interest. The bonds mature on January 31, 2018. Interest is paid semiannually on July 31 and January 31. Bowan's...
A salesperson must have a good understanding of the competition, customers, and everything connected with the...
A salesperson must have a good understanding of the competition, customers, and everything connected with the company. Why should a salesperson take time to be up-to-date on facts about the economy and the industry?
peer review please I have never heard of Gardners theory until now and I believe everything...
peer review please I have never heard of Gardners theory until now and I believe everything he says. Yes, it may be a little broad and lacking of evidence but it's true. We don't have one intelligence. We can be intelligent in many different subjects. Not knowing a lot about something that disinterests you does not make you unintelligent. Intelligence should be broken down into different topics, interests and subjects. Breaking it down this way helps many people find the...
I have the answers for everything, I just need for it to be explained as to...
I have the answers for everything, I just need for it to be explained as to why that's the answer. A 24-year old female automotive technician presents herself at the doctor’s office. She complains of fever and of pain in her left hand. On physical examination, the patient had a deep wound on her left palm that was oozing pus. She had purplish, red streaks running up her left arm. She had enlarged lymph nodes at the elbow and under...
This is C++ there are intruction and descriptions. Please give me the answer because I understand...
This is C++ there are intruction and descriptions. Please give me the answer because I understand the concept, but don't know how to put in the actual problem yet. Instructions and Assumptions Declare and implement the three functions described below. Your declarations should go in AnyList.h. Your definitions should go in Functions.cpp. For all of these functions, assume the list contains at least three elements. No need to consider the empty list cases. The Functions 1. Overload the insertion operator...
Mautz (1973) made the following comment: “Accounting is what it is today not so much because...
Mautz (1973) made the following comment: “Accounting is what it is today not so much because of the desire of accountants but because of the influence of businessmen. If those who make management an investment decisions had not found financial reports based on historical cost useful over the years, changes in accounting would long since have been made” Critically evaluate this statement. In your discussion, you should consider the relative merits of historical cost accounting as well as the various...
I think I have a little bit of understanding of input impedance impedance, but please check...
I think I have a little bit of understanding of input impedance impedance, but please check my understanding, and also explain physically what output impedance and reactance is AND EXPLAIN YOUR TERMINOLOGY or use basic af terminology: Input impedance describes (I think) a voltage source, or something that produces an output voltage, and its impedance within it's own circuitry. In other words, say I have a function generator, something supposed to output voltage, and the input impedance would be the...
Please comment on the paragraph. I have chosen the argument of global warming being a hoax....
Please comment on the paragraph. I have chosen the argument of global warming being a hoax. Global warming is the idea that earth’s atmosphere is being depleted due to increased levels of carbon dioxide and other pollutants. The antecedent argument supports the claim of global warming which is, if global warming is real, then the global temperatures will have risen. And that has happened, therefore, global warming is real. While I do believe we are leaving a carbon footprint I...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT