(Coderbyte) Check Nums - Solução

Have the function CheckNums(num1,num2) take both parameters being passed and return the string true if num2 is greater than num1, otherwise return the string false. If the parameter values are equal to each other then return the string -1.

Solução:

import java.util.*;
import java.io.*;

class Function { 
  String CheckNums(int num1, int num2) {
    String res = "";
    if (num1 > num2) {
        res = "false";
    }
    else if (num2 > num1) {
        res = "true";
    }
    else {
        res = "-1";
    }
   
    return res;
   
  }
 
  public static void main (String[] args) { 
    // keep this function call here    
    Scanner  s = new Scanner(System.in);
    Function c = new Function();
    System.out.print(c.CheckNums(s.nextLine()));
  }  
 
}           

Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução