Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

vprickapova avatar vprickapova 4 Точки

Problem 1. Bonus Scoring System

Здравейте колеги,

Имам проблем с крайният резултат на задача Bonus Score, условието е: 

Problem 1. Bonus Scoring System

Create a program that calculates bonus points for each student, for a certain course. On the first line, you are going to receive the count of the students for this course. On the second line, you will receive the count of the lectures in the course. Every course has an additional bonus. You are going to receive it on the third line. On the next lines, you will be receiving the count of attendances for each student.

The bonus is calculated with the following formula:

{total bonus} = {student attendances} / {course lectures} * (5 + {additional bonus})

Find the student with the maximum bonus and print him/her, along with his attendances in the following format:

"Max Bonus: {maxBonusPoints}."

"The student has attended {studentAttendances} lectures."

Round the bonus points at the end to the nearest bigger number.

Input / Constrains

  • On the first line you are going to receive the count of the students – an integer number in the range [0…50]
  • On the second line you are going to receive the count of the lectures – an integer number in the range [0...50].
  • On the third line you are going to receive the initial bonus – an integer number in the range [0….100].
  • On the next lines, you will be receiving the attendances of each student.
  • There will never be students with equal bonuses.

Output

  • Print the maximum bonus points along with the attendances of the given student, rounded to the nearest bigger number, scored by a student in this course in the format described above.

Examples

Input

Output

5

25

30

12

19

24

16

20

Max Bonus: 34.

The student has attended 24 lectures.

Comments

First, we receive the number of students enrolled in the course – 5. The total count of the lectures is 25 and the initial bonus is 30. Then we calculate the bonus of the student with 12 attendances, which is 16.8. We continue calculating each of the student’s bonuses. The one with 24 attendances has the highest bonus – 33.6 (34 rounded), so we print the appropriate message on the console.

10

30

14

8

23

27

28

15

17

25

26

5

18

Max Bonus: 18.

The student has attended 28 lectures.

Линк към кода: https://pastebin.com/EXUHYeWe,  Max Bonus: {maxBonusPoints}. е грешен при вторият тест, получавам отговор 23, а трябва да е равен на 18.

Ще съм Ви много благодарна, ако някой ми посочи грешката :)

Тагове:
0
JavaScript Fundamentals 01/07/2020 12:56:12
nickwork avatar nickwork 657 Точки

Проблема ти е, че не използваш правилно формулата => това students трябва да е просто цифрата 5..виж по условие

let totalBonus = (currentAttendences / lectures) * (students + additionalBonus);

Но само с тази корекция няма да ти даде 100/100...направи в самото начало проверка ако във входните данни има нули да ти вади правилният изход и можеш да прекъснеш там функцията.

0
vprickapova avatar vprickapova 4 Точки

Благодаря ти за бързият отговор nickwork, взех 100/100.

Хубав ден :)

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.