Computer Science, asked by ItzExoTicExploreR, 7 months ago

 \huge\orange {\boxed {\boxed {\mathtt {QuestiOn}}}}

Write a program in Java that accepts the seconds as input and converts them into the corresponding numbers of hours, minutes and seconds.
{use scanner}

• valuable description and documentation needed!

please don't spam :)​

Answers

Answered by REDPLANET
76

\underline{\boxed{\bold{Question}}}

  • Write a program in Java that accepts the seconds as input and converts them into the corresponding numbers of hours, minutes and seconds.
  • use "scanner".

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

\underline{\boxed{\bold{Introduction\;to\;JAVA}}}

  • Java is a programming language created by James Gosling from Sun Microsystems (Sun) in 1991, later acquired by Oracle Corporation. Work on the language began in 1991, and before long the team's focus changed to a new niche, the World Wide Web.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

\underline{\boxed{\bold{Coding\;of\;required\;program}}}

import java.util.Scanner;

public class SecondstoHrMinSec  

{

public static void main(String[] args)

{

 // create object of scanner class.

 Scanner in = new Scanner(System.in);

 // enter the seconds here.

 System.out.print("Enter seconds : ");

 int seconds = in.nextInt();  

 int p1 = seconds % 60;

 int p2 = seconds / 60;

 int p3 = p2 % 60;

 p2 = p2 / 60;

 System.out.print("HH:MM:SS - " +p2 + ":" + p3 + ":" + p1);

 System.out.print("\n");

}  

}

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

\underline{\boxed{\bold{Example\;of \:Outp \mu t \;of \;program}}}

Enter seconds : 6530

HH : MM : SS - 1 : 48 : 50

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Hope this helps u.../

【Brainly Advisor】

Answered by BrainlyProgrammer
2

\huge\star\underbrace{\mathtt\red{⫷❥Q} \mathtt\green{u}\mathtt\blue{E} \mathtt\purple{§}\mathtt\orange{T} \mathtt\pink{i} \mathtt\orange{O} \mathtt\green{n~⫸}}\star

  • Write a program in Java that accepts the seconds as input and converts them into the corresponding numbers of hours, minutes and seconds Using Scanner Class.

\huge\star\underbrace{\mathtt\red{⫷❥ᴀ᭄} \mathtt\green{n~ }\mathtt\blue{ §} \mathtt\purple{₩}\mathtt\orange{Σ} \mathtt\pink{R⫸}}\star

import java.util.*;

class second

{

public static void main (String ar [])

{

Scanner sc=new Scanner (System.in);

System.out.println("Enter number of seconds");

int sec=sc.nextInt();

int hr=0,min=0;

if (sec>=3600)

{

hr=sec/3600;

sec%=3600;

}

if(sec>=60)

{

min=sec/60;

sec%=60;

}

System.out.println("Hour:"+hr);

System.out.println("Minute:"+min);

System.out.println("Second:"+sec);

}

}

Sample Input:

Enter number of seconds

3606

Sample Output:

Hour:1

Min:0

Sec:6

Similar questions