<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="category">
    <category>
      <text>$course$/top/OnlineCompiler.io Java (español)</text>
    </category>
    <info format="html">
      <text><![CDATA[<p>Preguntas CodeRunner gratis de OnlineCompiler.io (https://onlinecompiler.io/es/banco-de-preguntas-coderunner), con licencia CC BY 4.0. Usan los tipos de pregunta que ya trae CodeRunner, así que funcionan en cualquier servidor Jobe.</p>]]></text>
    </info>
    <idnumber></idnumber>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Segundos a H:MM:SS]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe un programa que lea un entero <i>t</i> &ge; 0, una cantidad de segundos, y la imprima en horas, minutos y segundos con el formato <code>H:MM:SS</code>. Los minutos y los segundos siempre llevan dos dígitos; las horas llevan los dígitos que hagan falta y pueden pasar de 23.</p><p>Por ejemplo, para la entrada <code>3725</code> el programa imprime <code>1:02:05</code>.</p><p>Pista: la división entera (<code>/</code>) y el residuo (<code>%</code>) hacen casi todo el trabajo, y <code>System.out.printf</code> con <code>%02d</code> rellena un número con ceros a la izquierda hasta que tenga dos dígitos.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_program</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int total = in.nextInt();
        int hours = total / 3600;
        int minutes = total % 3600 / 60;
        int seconds = total % 60;
        System.out.printf("%d:%02d:%02d%n", hours, minutes, seconds);
    }
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[3725
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[1:02:05]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[59
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[0:00:59]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[0
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[0:00:00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[86399
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[23:59:59]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[90061
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[25:01:01]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[3600
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[1:00:00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>io</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Mayor de tres]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe un método <code>static int maxOfThree(int a, int b, int c)</code> que devuelva el mayor de sus tres argumentos. No uses <code>Math.max</code>.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[static int maxOfThree(int a, int b, int c) {
    int max = a;
    if (b > max) {
        max = b;
    }
    if (c > max) {
        max = c;
    }
    return max;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(maxOfThree(3, 9, 4))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[9]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(maxOfThree(-1, -7, -3))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[-1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(maxOfThree(5, 5, 2))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[5]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(maxOfThree(1, 2, 30))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[30]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>conditionals</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Año bisiesto]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe un método <code>static boolean isLeapYear(int year)</code> que devuelva <code>true</code> si <code>year</code> es un año bisiesto en el calendario gregoriano y <code>false</code> en caso contrario. Un año es bisiesto cuando es divisible entre 4, pero los años divisibles entre 100 solo son bisiestos si también son divisibles entre 400. Así, 2024 y 2000 son bisiestos, pero 2023 y 1900 no lo son. Puedes suponer que <code>year</code> &ge; 1.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[static boolean isLeapYear(int year) {
    return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isLeapYear(2024))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[true]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isLeapYear(2023))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[false]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isLeapYear(1900))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[false]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isLeapYear(2000))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[true]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isLeapYear(1600))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[true]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isLeapYear(2100))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[false]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>conditionals</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Suma de n números]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe un programa que lea un entero <i>n</i> y luego <i>n</i> enteros (separados por espacios o saltos de línea), e imprima su suma.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_program</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += in.nextInt();
        }
        System.out.println(sum);
    }
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[3
1 2 3
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[6]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[5
10
-4
7
0
2
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[15]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[0
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[1
-42
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[-42]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>loops</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Escalera de asteriscos]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe un método <code>static void printStaircase(int n)</code> que imprima una escalera de asteriscos de <code>n</code> líneas de alto, alineada a la derecha: la línea <i>i</i> (contando desde 1) tiene <i>n</i> &minus; <i>i</i> espacios seguidos de <i>i</i> asteriscos. Para <code>n</code> = 0 no imprime nada. El método imprime la escalera; no devuelve nada.</p><p>Por ejemplo, <code>printStaircase(4)</code> imprime:</p><pre>   *
  **
 ***
****</pre>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[static void printStaircase(int n) {
    for (int row = 1; row <= n; row++) {
        for (int i = 0; i < n - row; i++) {
            System.out.print(' ');
        }
        for (int i = 0; i < row; i++) {
            System.out.print('*');
        }
        System.out.println();
    }
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[printStaircase(4)]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[   *
  **
 ***
****]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[printStaircase(1)]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[*]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[printStaircase(2)]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[ *
**]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[printStaircase(0)]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[printStaircase(6)]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[     *
    **
   ***
  ****
 *****
******]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>loops</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Conversión de temperatura]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe dos métodos:</p><ul><li><code>static double toFahrenheit(double celsius)</code> devuelve la temperatura en grados Fahrenheit, usando <i>F</i> = <i>C</i> &times; 9 / 5 + 32;</li><li><code>static double toCelsius(double fahrenheit)</code> hace la conversión inversa, usando <i>C</i> = (<i>F</i> &minus; 32) &times; 5 / 9.</li></ul><p>Las pruebas imprimen cada resultado redondeado a dos decimales, con punto decimal; así, 100 &deg;C se comprueba como <code>212.00</code>. Recuerda que en Java la división de un <code>int</code> entre otro da un <code>int</code>: <code>9 / 5</code> vale 1.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[static double toFahrenheit(double celsius) {
    return celsius * 9 / 5 + 32;
}

static double toCelsius(double fahrenheit) {
    return (fahrenheit - 32) * 5 / 9;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(String.format(java.util.Locale.ROOT, "%.2f", toFahrenheit(100)))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[212.00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(String.format(java.util.Locale.ROOT, "%.2f", toCelsius(212)))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[100.00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(String.format(java.util.Locale.ROOT, "%.2f", toFahrenheit(-40)))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[-40.00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(String.format(java.util.Locale.ROOT, "%.2f", toFahrenheit(36.6)))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[97.88]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(String.format(java.util.Locale.ROOT, "%.2f", toCelsius(98.6)))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[37.00]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(String.format(java.util.Locale.ROOT, "%.2f", toCelsius(0)))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[-17.78]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>functions</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[MCD y MCM]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe dos métodos para enteros positivos <code>a</code> y <code>b</code>:</p><ul><li><code>static int gcd(int a, int b)</code> devuelve su máximo común divisor (MCD), el mayor entero que divide a ambos;</li><li><code>static int lcm(int a, int b)</code> devuelve su mínimo común múltiplo (MCM), el menor entero positivo que es múltiplo de ambos. Escríbelo llamando a <code>gcd</code>: MCM(<i>a</i>, <i>b</i>) = <i>a</i> / MCD(<i>a</i>, <i>b</i>) &times; <i>b</i>.</li></ul><p>Por ejemplo, <code>gcd(12, 18)</code> es 6 y <code>lcm(12, 18)</code> es 36. Las pruebas solo usan valores cuyo MCM cabe en un <code>int</code>.</p><p>El algoritmo de Euclides calcula el MCD rápidamente: mientras <i>b</i> no sea 0, reemplaza (<i>a</i>, <i>b</i>) por (<i>b</i>, <i>a</i> % <i>b</i>); al final, <i>a</i> es la respuesta.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[static int gcd(int a, int b) {
    while (b != 0) {
        int rest = a % b;
        a = b;
        b = rest;
    }
    return a;
}

static int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(gcd(12, 18) + " " + lcm(12, 18))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[6 36]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(gcd(7, 13) + " " + lcm(7, 13))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 91]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(gcd(5, 5) + " " + lcm(5, 5))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[5 5]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(gcd(1, 9) + " " + lcm(4, 6))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1 12]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(gcd(180, 48) + " " + lcm(180, 48))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[12 720]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(gcd(50000, 100000) + " " + lcm(50000, 100000))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[50000 100000]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>functions</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Iniciales de un nombre]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe un método <code>static String initials(String name)</code> que devuelva la primera letra de cada palabra de <code>name</code>, en mayúscula, todas juntas. Las palabras están separadas por uno o más espacios, y <code>name</code> también puede empezar o terminar con espacios. Si <code>name</code> no tiene ninguna palabra, devuelve la cadena vacía.</p><p>Por ejemplo, <code>initials("ada lovelace")</code> devuelve <code>"AL"</code>.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[static String initials(String name) {
    StringBuilder result = new StringBuilder();
    for (int i = 0; i < name.length(); i++) {
        boolean startsWord = name.charAt(i) != ' ' && (i == 0 || name.charAt(i - 1) == ' ');
        if (startsWord) {
            result.append(Character.toUpperCase(name.charAt(i)));
        }
    }
    return result.toString();
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(initials("ada lovelace"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[AL]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(initials("Alan Mathison Turing"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[AMT]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(initials("  clarice   lispector "))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[CL]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(initials("Turing"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[T]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(initials(" jorge  luis borges"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[JLB]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println("[" + initials("   ") + "]" + "[" + initials("") + "]")]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[[][]]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>strings</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Verificar palíndromo]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Un palíndromo se lee igual de derecha a izquierda que de izquierda a derecha. Escribe un método <code>static boolean isPalindrome(String text)</code> que devuelva <code>true</code> si <code>text</code> es un palíndromo cuando ignoras la diferencia entre mayúsculas y minúsculas y descartas todo carácter que no sea letra ni dígito (espacios, signos de puntuación, etc.), y <code>false</code> en caso contrario. Un texto sin letras ni dígitos, como la cadena vacía, cuenta como palíndromo.</p><p>Por ejemplo, <code>"Radar"</code> y <code>"Anita lava la tina"</code> son palíndromos, pero <code>"Java"</code> no lo es. <code>Character.isLetterOrDigit</code> y <code>Character.toLowerCase</code> te van a ayudar.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[static boolean isPalindrome(String text) {
    StringBuilder kept = new StringBuilder();
    for (char c : text.toCharArray()) {
        if (Character.isLetterOrDigit(c)) {
            kept.append(Character.toLowerCase(c));
        }
    }
    String forwards = kept.toString();
    String backwards = kept.reverse().toString();
    return forwards.equals(backwards);
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isPalindrome("Radar"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[true]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isPalindrome("Java"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[false]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isPalindrome("Anita lava la tina"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[true]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isPalindrome("Roma me tem amor!"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[true]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isPalindrome("Never odd or even"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[true]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(isPalindrome("") + " " + isPalindrome("1, 2, 1") + " " + isPalindrome("abca"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[true true false]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>strings</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Posición del mayor]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe un método <code>static int indexOfMax(int[] values)</code> que devuelva el índice del mayor valor del arreglo <code>values</code>. Si el mayor valor aparece más de una vez, devuelve el menor de sus índices (la primera posición en la que aparece). Si el arreglo está vacío, devuelve <code>-1</code>. Los valores pueden ser negativos.</p><p>Por ejemplo, para <code>{4, 9, 2, 9}</code> el método devuelve 1.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[static int indexOfMax(int[] values) {
    if (values.length == 0) {
        return -1;
    }
    int best = 0;
    for (int i = 1; i < values.length; i++) {
        if (values[i] > values[best]) {
            best = i;
        }
    }
    return best;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(indexOfMax(new int[] {4, 9, 2, 7}))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(indexOfMax(new int[] {-5, -2, -9}))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(indexOfMax(new int[] {3, 8, 8, 1}))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(indexOfMax(new int[] {}))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[-1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(indexOfMax(new int[] {42}))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(indexOfMax(new int[] {1, 2, 3, 4, 5}))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[4]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>lists</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Por encima del promedio]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe un programa que lea números enteros hasta el final de la entrada. Vienen separados por espacios o saltos de línea, y puede que no haya ninguno. Imprime, en una línea y separados por un espacio, los números que son estrictamente mayores que el promedio de todos los números leídos, en el orden en que se leyeron. Si ningún número está por encima del promedio, imprime una línea vacía.</p><p>Por ejemplo, para la entrada <code>4 8 6 2</code> el promedio es 5, así que el programa imprime <code>8 6</code>.</p><p>No sabes de antemano cuántos números habrá, así que guárdalos en un <code>ArrayList&lt;Integer&gt;</code>. El método <code>hasNextInt()</code> de <code>Scanner</code> te dice si todavía queda un entero por leer.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_program</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>20</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        ArrayList<Integer> numbers = new ArrayList<>();
        long sum = 0;
        while (in.hasNextInt()) {
            int value = in.nextInt();
            numbers.add(value);
            sum += value;
        }
        double average = numbers.isEmpty() ? 0 : (double) sum / numbers.size();
        StringBuilder line = new StringBuilder();
        for (int value : numbers) {
            if (value > average) {
                if (line.length() > 0) {
                    line.append(' ');
                }
                line.append(value);
            }
        }
        System.out.println(line);
    }
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[4 8 6 2
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[8 6]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[1 2 3 4 5 6 7 8 9 10
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[6 7 8 9 10]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[-3
-1
-2
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[-1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[7 7 7
]]></text>
        </stdin>
        <expected>
          <text></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text></text>
        </testcode>
        <stdin>
          <text><![CDATA[-3 -2
]]></text>
        </stdin>
        <expected>
          <text><![CDATA[-2]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>lists</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Palabra más frecuente]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe un método <code>static String mostFrequentWord(String text)</code> que devuelva la palabra que más aparece en <code>text</code>. Si varias palabras empatan con la mayor cantidad de apariciones, devuelve la que aparece primero en <code>text</code>. <code>text</code> tiene al menos una palabra; las palabras están separadas por un solo espacio, sin espacios al principio ni al final, y se comparan exactamente como están escritas (<code>"Sol"</code> y <code>"sol"</code> son palabras distintas).</p><p>Por ejemplo, <code>mostFrequentWord("do re mi do")</code> devuelve <code>"do"</code>.</p><p>Cuenta las palabras con un <code>HashMap&lt;String, Integer&gt;</code>. CodeRunner pone tu método dentro de una clase propia, así que no hay dónde escribir un <code>import</code>: usa el nombre completo, <code>java.util.HashMap</code>.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[static String mostFrequentWord(String text) {
    String[] words = text.split(" ");
    java.util.HashMap<String, Integer> counts = new java.util.HashMap<>();
    for (String word : words) {
        counts.put(word, counts.getOrDefault(word, 0) + 1);
    }
    String best = words[0];
    for (String word : words) {
        if (counts.get(word) > counts.get(best)) {
            best = word;
        }
    }
    return best;
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(mostFrequentWord("do re mi do"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[do]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(mostFrequentWord("la si la si si"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[si]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(mostFrequentWord("fa sol sol fa"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[fa]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(mostFrequentWord("mi"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[mi]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(mostFrequentWord("sol fa fa sol"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[sol]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(mostFrequentWord("Re re re Re do Re"))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[Re]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>maps</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Cuenta bancaria]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe una clase <code>BankAccount</code> que guarda un saldo en unidades enteras de dinero. Tiene:</p><ul><li>un constructor <code>BankAccount(int initialBalance)</code>, con <code>initialBalance</code> &ge; 0;</li><li><code>int getBalance()</code>, que devuelve el saldo actual;</li><li><code>void deposit(int amount)</code>, que suma <code>amount</code> al saldo, pero no hace nada si <code>amount</code> es cero o negativo;</li><li><code>boolean withdraw(int amount)</code>, que retira <code>amount</code> del saldo y devuelve <code>true</code>. Si <code>amount</code> es cero, negativo o mayor que el saldo, deja el saldo como está y devuelve <code>false</code>.</li></ul><p>Guarda el saldo en un atributo <code>private</code>, para que la única forma de cambiarlo sea mediante estos métodos. Cada cuenta tiene su propio saldo.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_class</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>25</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[public class BankAccount {
    private int balance;

    public BankAccount(int initialBalance) {
        balance = initialBalance;
    }

    public int getBalance() {
        return balance;
    }

    public void deposit(int amount) {
        if (amount > 0) {
            balance += amount;
        }
    }

    public boolean withdraw(int amount) {
        if (amount <= 0 || amount > balance) {
            return false;
        }
        balance -= amount;
        return true;
    }
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[BankAccount account = new BankAccount(100);
account.deposit(50);
System.out.println(account.getBalance())]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[150]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[BankAccount account = new BankAccount(100);
System.out.println(account.withdraw(30));
System.out.println(account.getBalance())]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[true
70]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[BankAccount account = new BankAccount(20);
System.out.println(account.withdraw(50));
System.out.println(account.getBalance())]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[false
20]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[BankAccount account = new BankAccount(20);
System.out.println(account.withdraw(20));
System.out.println(account.getBalance())]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[true
0]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[BankAccount account = new BankAccount(100);
account.deposit(-10);
account.deposit(0);
System.out.println(account.withdraw(-5) + " " + account.withdraw(0));
System.out.println(account.getBalance())]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[false false
100]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[BankAccount first = new BankAccount(10);
BankAccount second = new BankAccount(5);
first.deposit(1);
second.withdraw(2);
System.out.println(first.getBalance() + " " + second.getBalance())]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[11 3]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>classes</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Fracciones]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Escribe una clase <code>Fraction</code> para fracciones de enteros, siempre guardadas en su forma irreducible y con denominador positivo. Tiene:</p><ul><li>un constructor <code>Fraction(int numerator, int denominator)</code>, donde <code>denominator</code> nunca es 0. Guarda la fracción en su forma irreducible, con el signo en el numerador: <code>new Fraction(6, -8)</code> guarda &minus;3/4, y cualquier fracción igual a cero se guarda como 0/1;</li><li><code>int getNumerator()</code> y <code>int getDenominator()</code>;</li><li><code>Fraction plus(Fraction other)</code> y <code>Fraction times(Fraction other)</code>, que devuelven una nueva <code>Fraction</code> con la suma o el producto y no modifican ninguna de las dos fracciones;</li><li><code>String toString()</code>, que devuelve el numerador, una barra y el denominador, como <code>"-3/4"</code>, <code>"5/1"</code> o <code>"0/1"</code>.</li></ul><p>Las pruebas usan números pequeños, así que todos los resultados caben en un <code>int</code>. Pista: para simplificar una fracción, divide el numerador y el denominador entre su máximo común divisor.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_class</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>30</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[public class Fraction {
    private final int numerator;
    private final int denominator;

    public Fraction(int numerator, int denominator) {
        if (denominator < 0) {
            numerator = -numerator;
            denominator = -denominator;
        }
        int divisor = gcd(Math.abs(numerator), denominator);
        this.numerator = numerator / divisor;
        this.denominator = denominator / divisor;
    }

    private static int gcd(int a, int b) {
        while (b != 0) {
            int rest = a % b;
            a = b;
            b = rest;
        }
        return a;
    }

    public int getNumerator() {
        return numerator;
    }

    public int getDenominator() {
        return denominator;
    }

    public Fraction plus(Fraction other) {
        return new Fraction(numerator * other.denominator + other.numerator * denominator,
                denominator * other.denominator);
    }

    public Fraction times(Fraction other) {
        return new Fraction(numerator * other.numerator, denominator * other.denominator);
    }

    @Override
    public String toString() {
        return numerator + "/" + denominator;
    }
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(new Fraction(6, 8))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[3/4]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Fraction half = new Fraction(1, 2);
Fraction third = new Fraction(1, 3);
System.out.println(half.plus(third) + " " + half.times(third))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[5/6 1/6]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(new Fraction(3, -6) + " " + new Fraction(-4, -2) + " " + new Fraction(0, -5))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[-1/2 2/1 0/1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Fraction f = new Fraction(-10, 4);
System.out.println(f.getNumerator() + " " + f.getDenominator())]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[-5 2]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[Fraction quarter = new Fraction(1, 4);
Fraction sum = quarter.plus(quarter);
Fraction product = quarter.times(quarter);
System.out.println(quarter + " " + sum + " " + product)]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[1/4 1/2 1/16]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[System.out.println(new Fraction(-1, 2).plus(new Fraction(1, 2)) + " " + new Fraction(-2, 3).times(new Fraction(-3, 2)))]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[0/1 1/1]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>classes</text></tag>
    </tags>
  </question>
  <question type="coderunner">
    <name>
      <text><![CDATA[Torres de Hanói]]></text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>En el rompecabezas de las Torres de Hanói, <i>n</i> discos de distintos tamaños están apilados en una de tres varillas, con el más grande abajo. El objetivo es llevarlos todos a otra varilla, moviendo un disco a la vez y sin poner nunca un disco sobre otro más pequeño.</p><p>Escribe un método recursivo <code>static void hanoi(int n, char from, char to, char spare)</code> que imprima los movimientos de la solución más corta para llevar <code>n</code> discos de la varilla <code>from</code> a la varilla <code>to</code>, usando <code>spare</code> como varilla auxiliar. Imprime un movimiento por línea: la varilla de donde sale el disco, un espacio, <code>-&gt;</code>, un espacio y la varilla a la que va, como en <code>A -&gt; C</code>. Para <code>n</code> = 0 el método no imprime nada.</p><p>Por ejemplo, <code>hanoi(2, 'A', 'C', 'B')</code> imprime:</p><pre>A -&gt; B
A -&gt; C
B -&gt; C</pre><p>Pista: antes de que el disco más grande pueda moverse, ¿dónde tienen que estar los otros <i>n</i> &minus; 1 discos?</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <hidecheck>0</hidecheck>
    <showsource>0</showsource>
    <answerboxlines>15</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer><![CDATA[static void hanoi(int n, char from, char to, char spare) {
    if (n == 0) {
        return;
    }
    hanoi(n - 1, from, spare, to);
    System.out.println(from + " -> " + to);
    hanoi(n - 1, spare, to, from);
}
]]></answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <attachments>0</attachments>
    <testcases>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[hanoi(1, 'A', 'C', 'B')]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[A -> C]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[hanoi(2, 'A', 'C', 'B')]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[A -> B
A -> C
B -> C]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[hanoi(3, 'A', 'C', 'B')]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[A -> C
A -> B
C -> B
A -> C
B -> A
B -> C
A -> C]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[SHOW]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[hanoi(0, 'A', 'C', 'B')]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000">
        <testcode>
          <text><![CDATA[hanoi(3, 'X', 'Y', 'Z')]]></text>
        </testcode>
        <stdin>
          <text></text>
        </stdin>
        <expected>
          <text><![CDATA[X -> Y
X -> Z
Y -> Z
X -> Y
Z -> X
Z -> Y
X -> Y]]></text>
        </expected>
        <extra>
          <text></text>
        </extra>
        <display>
          <text><![CDATA[HIDE]]></text>
        </display>
      </testcase>
    </testcases>
    <tags>
      <tag><text>onlinecompiler.io</text></tag>
      <tag><text>java</text></tag>
      <tag><text>recursion</text></tag>
    </tags>
  </question>
</quiz>
