Guest User

Untitled

a guest
Mar 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package el.reloj.se.atrasa;
  7.  
  8. import java.io.BufferedReader;
  9. import java.io.IOException;
  10. import java.io.InputStreamReader;
  11. import java.util.Scanner;
  12.  
  13. /**
  14. *
  15. * @author david
  16. */
  17. public class ElRelojSeAtrasa {
  18.  
  19. /**
  20. * @param args the command line arguments 1: Cuanto se atrasa durante el dia
  21. * 2:Cuanto se adelanta por la noche 3:Dias a contabilizar
  22. */
  23. public static void main(String[] args) throws IOException {
  24. int i, casos = 0, a, b, t;
  25. BufferedReader teclado2 = new BufferedReader(new InputStreamReader(System.in));
  26. String cadena[], linea = " ";
  27. Scanner teclado = new Scanner(System.in);
  28. casos = teclado.nextInt();
  29. do {
  30.  
  31. linea = teclado2.readLine();
  32. cadena = linea.split(" ");
  33.  
  34. if (Integer.parseInt(cadena[0]) < Integer.parseInt(cadena[1])) {
  35. System.out.println("El reloj se adelanta");
  36. } else if (Integer.parseInt(cadena[0]) == Integer.parseInt(cadena[1])) {
  37. System.out.println("El reloj es puntual");
  38.  
  39. } else {//Es mas grande la posicion 0, porque indica lo que se atrasa
  40. a = Integer.parseInt(cadena[0]);
  41. b = Integer.parseInt(cadena[1]);
  42. t = Integer.parseInt(cadena[2]);
  43. a *= t;
  44. a -= (b * t);
  45.  
  46. b = 0;//reutilizo esta variable
  47. while (a > 0) {//Solo funciona mientras que sea a mayor a 0, si es menor se corrige con el if de abajo
  48. b++;
  49. a -= 60;
  50. }
  51. if (a < 0) {
  52. b--;
  53. a += 60;
  54. }
  55. if (b < 10 && a < 10) {
  56. System.out.println("0" + b + ":0" + a);
  57. } else if (b < 10 && a > 10) {
  58. System.out.println("0" + b + ":" + a);
  59. } else if (b > 10 && a < 10) {
  60. System.out.println(b + ":0" + a);
  61. }
  62.  
  63. }
  64. casos--;
  65. } while (casos > 0);
  66. }
  67. }
Add Comment
Please, Sign In to add comment