Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Source Code: Never mind. This question has been solved by the Chegg user. Please close the question. HackerLand University has the following grading policy:

C++ Source Code: Never mind. This question has been solved by the Chegg user. Please close the question.

HackerLand University has the following grading policy:

Every student receives a in the inclusive range from to .

Any less than is a failing grade.

Sam is a professor at the university and likes to round each student's according to these rules:

If the difference between the and the next multiple of is less than , round up to the next multiple of .

If the value of is less than , no rounding occurs as the result will still be a failing grade.

For example, will be rounded to but will not be rounded because the rounding would result in a number that is less than .

Given the initial value of for each of Sam's students, write code to automate the rounding process. Complete the function solve that takes an integer array of all grades, and return an integer array consisting of the rounded grades. For each , round it according to the rules above and print the result on a new line.

Input Format

The first line contains a single integer denoting (the number of students). Each line of the subsequent lines contains a single integer, , denoting student 's grade.

Constraints

Output Format

For each of the grades, print the rounded grade on a new line.

Sample Input 0

4 73 67 38 33 

Sample Output 0

75 67 40 33 

Explanation 0

student submitted image, transcription available below

Student received a , and the next multiple of from is . Since , the student's grade is rounded to .

Student received a , and the next multiple of from is . Since , the grade will not be modified and the student's final grade is .

Student received a , and the next multiple of from is . Since , the student's grade will be rounded to .

Student received a grade below , so the grade will not be modified and the student's final grade is .

Question: Why am I getting an array with a first nonzero element followed by a bunch of zeros?

Source Code:

vector gradingStudents(vector grades) { /* * Write your code here. */ int i =grades.size() -1; vector newgrades(grades.size()); for(int i ; i >=0; i--){ if (grades[i] % 5 < 3 && !(grades[i] < 38)) { newgrades[i] = grades[i] + (5 - (grades[i] % 5)); } else{ newgrades[i] = grades[i]; } } return newgrades; }

Wrong Answer :(

Your code did not pass all the sample testcases.

Testcase 0

Input (stdin)

4 73 67 38 33

Your Output (stdout)

73 0 0 0 

Expected Output

75 67 40 33

Compiler Message

Wrong Answer

Question: Why am I getting an array with a first nonzero element followed by a bunch of zeros?

ID Original Grade Final Grade 2 3 4 73 67 38 75 67 40

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+ f. instituting laws against driving while intoxicated

Answered: 1 week ago

Question

=+ Why have these changes occurred?

Answered: 1 week ago