6.4.. Napisati program koji vrijeme učitano u satima, minutama i sekundama izračunava i ispisuje u sekundama.

Opis rješenja:

Opis programa:

Listing programa:

package zadatak;
import java.util.Scanner;
public class P06411127 {
    public static void main(String[] args)	{
    Scanner input = new Scanner (System.in);
	
		System.out.print("Unesi sate: ");
		double s=input.nextDouble();
		System.out.print("Unesi minute: ");
		double m=input.nextDouble();
		System.out.print("Unesi sekunde: ");
		double sec=input.nextDouble();
		
		System.out.print("Vrijeme u sekundama je: " +(s*3600+m*60+s));
}}
II Varijanta
package zadatak;
import java.util.Scanner;
public class P06411127 {
    public static void main(String[] args)	{
    Scanner input = new Scanner (System.in);

		System.out.println("unijeti sate minute i sekunde");
		int a = input.nextInt();
		int b = input.nextInt();
		int c = input.nextInt();
                int x = a*3600+b*60+c;
		System.out.println("U sekundama dato vrijeme iznosi:  "  +  x);

}}

Ispis na ekranu:

Index