Problem 11. ratingcontest.js

Rating Contest
A programming competition site regularly holds programming
contests at different levels.

The first level contest is called ABC, which is open for contestants
with ranking less than 1200.

The contest level after the ABC is called ARC, which is open for
contestants with ranking less than 2800.

The contest level after the ARC is called AGC, which is open for all contestants.

Help Ramesh in figuring out which is the next level for him given his
current rank 'R'.

Input
One Integer, denoting R.

Output
Print the name of the next contest rated for Ramesh (ABC, ARC or AGC).

Example
Input1:

1199
Output1:

ABC
Explanation1:

1199 is less than 1200, so ABC will be rated.
Input2:

1200
Output2:

ARC
*/

let fs = require("fs");
let data = fs.readFileSync(0, 'utf-8');
let idx = 0;
data = data.split('\n');

function readLine() {
idx++;
return data[idx - 1].trim();
}
//...........................................................................................

let rank = parseInt(readLine()); // 1. 1199 2. 1200

if (rank < 1200) {
console.log('ABC'); // 1199 < 1200 true therefore 'ABC' is printed in the console for
first test case.
}

else if (rank < 2800) {
console.log('ARC'); // 1200 < 2800 true therefore 'ARC' is printed in the console
for 2nd test case.
}

else {
console.log('AGC');
}

Terminal:
Nobins-MacBook-Pro:STOC_MODULE 11SEPT 2022 nobinpunyo$ node ratingcontest.js <input.txt ABC

Nobins-MacBook-Pro:STOC_MODULE 11SEPT 2022 nobinpunyo$ node ratingcontest.js <input.txt
ARC


Comments

Popular posts from this blog

Problem 33. patter122333.js

Problem 38. diamond.js

Problem 16. chocolatebills.js