Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create Programs C++ 1)Write a program that receives a serials of students grades

ID: 3578462 • Letter: C

Question

Create Programs C++

1)Write a program that receives a serials of students grades from the standard input and computes the average grade after the lowest grade is dropped.

The program should keep on reading the grades until it receives -1 as the end of the input.

The program should validate all the grades user entered are no greater than100 and no less than 0.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

2) You have $40 to buy three kinds of fruits: apple, watermelon and lemon. Suppose apples are 40 cents each. watermelon are 4$ each and lemons are 20 cents each. You have to buy at least one for each kind. Can you write a program that prints out all the possible combinations that use all the budget? for example: apple: 10;  watermelon: 8;   lemon:20.

[Hint: use nested loop]

Explanation / Answer

1. #include<vector>

#include<iterator>

void main()

{

vector<int> scores;

int a,location,i;

do

{

cin>>a;

if(a>0 and a<100)

scores.push(a);

}while(a!=-1);

vector<int>::iterator it;

it=min_element(scores.begin(),scores.end());

location= distance(it,scores.begin());

first.erase(location);
   for(i=0;i<score.size();i++)

{

sum=sum+scores[i];

}

avg= sum/scores.size();

cout<<avg;

}

-----------------------------------------------------------------------------------------------------------

2.