Hackerrank Algorithm Mars Exploration Solution in Java
Caesar Cipher Hackerrank Algorithm Solution in Java
Given the initial value of grade for each of Sams students, write code to automate the rounding process. For each gradei, round it according to the rules above and print the result on a new line.
Student 3 received a 38, and the next multiple of 5 from 38 is 40.Since 40 38
Sam is a professor at the university and likes to round each students grade according to these rules:
The first line contains a single integer denoting n(the number of students).
Hello Friends, in this tutorial we are going to learn Hackerrank Algorithm
Super Reduced String Hackerrank Algorithm Solution in Java
HackerLand University has the following grading policy:
For example, grade = 84 will be rounded to 85 but grade = 29 will not be rounded because the rounding would result in a number that is less than 40.
package com.hackerranksolution.algorithms.Implementation; import java.util.Scanner; /** * * @author Milind */ public class GradingStudents public static void main(String args) Scanner in = new ); int n = in.nextInt(); int arr = new int[n]; for (int i = 0; i n; i++) int grade = in.nextInt(); if (grade 38) arr[i] = grade; else int f1 = grade + 1; int f2 = grade + 2; if (f1 % 5 == 0) arr[i] = f1; else if (f2 % 5 == 0) arr[i] = f2; else arr[i] = grade; for (int i = 0; i n; i++) System.out.println(arr[i]);
How to create immutable class in java
CamelCase Hackerrank Algorithm Solution in Java
If the difference between the grade and the next multiple 5 of is less 3 than , round grade up to the next multiple of 5.
Each line i of the n subsequent lines contains a single integer, gradei, denoting student is grade.
If the value of is less than 38, no rounding occurs as the result will still be a failing grade.
For each of the grades, print the rounded grade on a new line.
Student 1 received a 73, and the next multiple of 5 from 73 is 73. Since 75-73
Student 4 received a grade below 38, so the grade will not be modified and the students final grade is 33.
Student 2 received a 67, and the next multiple of 5 from 67 is 70. Since 70-67 =3, the grade will not be modified and the students final grade is 67.