The JEE
Description
JEE is one of the most prestigious exams. You need to implement ranking rule in it. Given marks of Physics, Chemistry and Mathematics of two students, Find out the winner using below rules:
=> If total marks of one student is greater than other, he/she wins
=> If total marks of both the students are same, then the one having more marks in Maths wins. In case their marks in maths are also same, the one whose marks in Physics is more wins the game.
Input
Input Format :
First line of input contains 3 space separated integers which is the marks in physics, chemistry and mathematics respectively of first student
Second line of input contains 3 space separated integers which is the marks in physics, chemistry and mathematics respectively of second student
Constraints :
Marks < 36000
Output
Output "First" (without quotes) if first student wins.
In all other case print "Second"
Hint
Output Explanation :
Both students have equal total marks, that is 280 but second student has more marks in Maths, so he wins (gets better rank)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double[] stud1 = new double[3];
double[] stud2 = new double[3];
double total1= 0;
double total2= 0;
for(int i = 0;i<=2;i++){
stud1[i]=sc.nextDouble();
total1+=stud1[i];
}
for(int i = 0;i<=2;i++){
stud2[i]=sc.nextDouble();
total2+=stud2[i];
}
if (total1>total2){
System.out.println("First");
}else if (total2>total1){
System.out.println("Second");
}else {
if (stud1[2]>stud2[2]){
System.out.println("First");
}else if (stud1[2]<stud2[2]){
System.out.println("Second");
}else if (stud1[0]>stud2[0]){
System.out.println("First");
}else if (stud1[0]<stud2[0]){
System.out.println("Second");
}
}
}
}
No comments:
Post a Comment