Ad
Code
Diff
  • public class Kumite {
      public static String highAndLow(String numbers) {
        String[] integerStrings = numbers.split(" "); 
        int maxValue = Integer.parseInt(integerStrings[0]);
        int minValue = Integer.parseInt(integerStrings[0]);
        
        for (int i = 1; i < integerStrings.length; i++){
          int number = Integer.parseInt(integerStrings[i]); 
          if(number > maxValue){
            maxValue = number;
          }
          if(number < minValue){
            minValue = number;
          }
        }
      return Integer.toString(maxValue) + " " + Integer.toString(minValue);
      }
    }
    
    • public class ns {
    • public static String highAndLow(String numbers) {
    • String[] integerStrings = numbers.split(" ");
    • int[] integers = new int[integerStrings.length];
    • for (int i = 0; i < integers.length; i++){
    • integers[i] = Integer.parseInt(integerStrings[i]);
    • }
    • int maxValue = integers[0];
    • for(int y=1;y < integers.length;y++){
    • if(integers[y] > maxValue){
    • maxValue = integers[y];
    • }
    • }
    • int minValue = integers[0];
    • for(int q=1;q<integers.length;q++){
    • if(integers[q] < minValue){
    • minValue = integers[q];
    • }
    • }
    • String s = Integer.toString(maxValue);
    • String m = Integer.toString(minValue);
    • String r = s + " " + m;
    • return r;
    • public class Kumite {
    • public static String highAndLow(String numbers) {
    • String[] integerStrings = numbers.split(" ");
    • int maxValue = Integer.parseInt(integerStrings[0]);
    • int minValue = Integer.parseInt(integerStrings[0]);
    • for (int i = 1; i < integerStrings.length; i++){
    • int number = Integer.parseInt(integerStrings[i]);
    • if(number > maxValue){
    • maxValue = number;
    • }
    • if(number < minValue){
    • minValue = number;
    • }
    • }
    • return Integer.toString(maxValue) + " " + Integer.toString(minValue);
    • }
    • }
    • public static void main(String args[]) {
    • System.out.println(highAndLow("13 48 19 20 24 12"));
    • }
    • }