Question

Write a class AdjustedAssignment that has private attributes for Name and a vector of integers Scores....

Write a class AdjustedAssignment that has private attributes for Name and a vector of integers Scores.

Add public set and get methods for Name

Write a public method addScore that accepts an integer and add it's to the score vector

write public methods for maximum, minimum and average - but before calculating, find the difference between the highest score and 100, and when calculating max, min and average, add that value to the result ( don't actually change the values in the vector in case a new highest score is added ).

For example, if I had the scores 70, 75, 80, 85, 90 - the average would be 80, the max would be 90 and the min would be 70, but the adjusted values would be 10 higher, because 100 - the max is 10. Adjusted average 90, adjusted max 100, adjusted min 80

Write a method that returns a Boolean value for if the average is at least 75

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

Please find the code below::

#include <iostream>
#include <string>
#include <vector>

using namespace std;

class AdjustedAssignment {
private:
   string name;
   vector<int> scores;
public:
   void setName(string n){
       name = n;
   }
   string getName(){
       return name;
   }

   void addScore(int n){
       scores.push_back(n);
   }

   int getMaximum(){
       int max = -9999;
       for(unsigned int i=0;i<scores.size();i++){
           if(max<scores[i]){
               max = scores[i];
           }
       }
       return max;
   }

   int getMinimum(){
       int min = 9999;
       for(unsigned int i=0;i<scores.size();i++){
           if(min>scores[i]){
               min = scores[i];
           }
       }
       return min;
   }

   int getAverage(){
       float total = 0;
       for(unsigned int i=0;i<scores.size();i++){
           total += scores[i];
       }
       return total/scores.size();
   }

   bool ifAverageAbove75(){
       float average = getAverage();
       return average>=75;
   }
};

int main()
{
   AdjustedAssignment assign;
   assign.setName("My Name");
   assign.addScore(70);
   assign.addScore(75);
   assign.addScore(80);
   assign.addScore(85);
   assign.addScore(90);

   int max = assign.getMaximum();
   int min = assign.getMinimum();
   float average = assign.getAverage();

   int diff = 100-max;

   int newMax = max+diff;
   int newMin = min+diff;
   float newAvg = average+diff;

   cout<<"Adjusted Maximum is : "<<newMax<<endl;
   cout<<"Adjusted Minimum is : "<<newMin<<endl;
   cout<<"Adjusted Average is : "<<newAvg<<endl;


   return 0;
}


output:

Add a comment
Know the answer?
Add Answer to:
Write a class AdjustedAssignment that has private attributes for Name and a vector of integers Scores....
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 instantiates an array of integers named scores. Let the size of the...

    Write a program that instantiates an array of integers named scores. Let the size of the array be 10. The program then first invokes randomFill to fill the scores array with random numbers in the range of 0 -100. Once the array is filled with data, methods below are called such that the output resembles the expected output given. The program keeps prompting the user to see if they want to evaluate a new set of random data. Find below...

  • write a class encapsulating the concept of a student assuming that the student has the following...

    write a class encapsulating the concept of a student assuming that the student has the following attributes the name of student the average of the student the rite a class encapsulating the concept of a Student, assuming that the Student has the following attributes: the name of the student, the average of the student, and the student's GPA. Include a default constructor, an overloaded constructor, the accessors and mutators, and methods, toString() and equals(). Also include a method returning the...

  • Assignment W3-2 This programming assignment addresses: •Compiling and Executing an App with more than 1 class...

    Assignment W3-2 This programming assignment addresses: •Compiling and Executing an App with more than 1 class •Initializing Objects using Constructors •Software Engineering with Private Instances Variables and Public Set/Get Methods •Uses Methods inside classes Description: You are asked to write a program to process two students’ scores. Each student will have scores for 3 tests, the user will input each student’s full name followed by their three scores. When the data for the two students are read from the keyboard,...

  • Write the definition of the class Tests such that an object of this class can store...

    Write the definition of the class Tests such that an object of this class can store a student's first name, last name, five test scores, average test score, and grade. (Use an array to store the test scores.) Add constructors and methods to manipulate data stored in an object. Among other things, your class must contain methods to calculate test averages, return test averages, calculate grades, return grades, and modify individual test scores. The method toString must return test data...

  • please help asap in c++, you dont have to do everything but at least give me...

    please help asap in c++, you dont have to do everything but at least give me a starting idea of how this should look like Write a class Assignment that has private attributes for Name, Possible Points and Earned Points Write a class Student that has private attributes for name and a vector of assignments. The constructor method should require a name. Add a method for get total score that returns the total number of points earned divided by the...

  • Determine the average of test scores. When completing this question, remember the order of operations. Write...

    Determine the average of test scores. When completing this question, remember the order of operations. Write a program that calculates an average of five test scores. The output will display the average test score. Get the first test score. Get the second test score. Get the third test score. Get the fourth test score. Get the fifth test score. Calculate the average by adding 5 test scores and dividing the sum by 5. Display the average. Make sure you add...

  • [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:...

  • Write a class Store which includes the attributes: store name, city. Write another class encapsulating an...

    Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method returning the...

  • IN JAVA Write a class Store which includes the attributes: store name, city. Write another class...

    IN JAVA Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method...

  • Write a class called Student. The specification for a Student is: Three Instance fields name -...

    Write a class called Student. The specification for a Student is: Three Instance fields name - a String of the student's full name totalQuizScore - double numQuizesTaken - int Constructor Default construtor that sets the instance fields to a default value Parameterized constructor that sets the name instance field to a parameter value and set the other instance fields to a default value. Methods setName - sets or changes the student name by taking in a parameter getName - returns...

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