UNA HERMOSA MOTO

UNA HERMOSA MOTO

miércoles, 22 de abril de 2015

Problema Resuelto 25


25.- DADO LA HORA, MINUTO Y SEGUNDO, ENCONTRAR LA HORA DEL SIGUIENTE SEGUNDO.

Resultado de imagen para HORA MINUTO SEGUNDO

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package problema0025;
import java.io.*;
/**
 *
 * @author abel montalvan
 */
public class Problema0025 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
  int h,m,s;
 BufferedReader in=new BufferedReader(new  InputStreamReader(System.in));
 System.out.println("Hora: ");
 h= Integer.parseInt(in.readLine());
 System.out.println("Minuto: ");
 m=Integer.parseInt(in.readLine());
 System.out.println("Segundo: ");
 s= Integer.parseInt(in.readLine());

 s+=1;
 if (s==60)
 {
     s=0;
     m+=1;
     if(m==60)
     {
        m=0;
        h+=1;
        if(h==24)
     {
         h=0;
        }
     }
  }
 System.out.println("");
 System.out.println("Hora: " + h);
 System.out.println("Minuto: " + m);
 System.out.println("Segundo: " + s);
 System.out.println();
   
    }
}

No hay comentarios:

Publicar un comentario