SlideShare a Scribd company logo
1 of 5
Download to read offline
ConvertingSeconds.java
import java.util.Scanner;
public class ConvertingSeconds {
public static void main(String[] args) {
//Declaring variables
int fromseconds,hours,minutes,seconds,toSeconds;
//Scanner class Object is used to read the inputs entered by the user
Scanner sc=new Scanner(System.in);
//getting the number of seconds entered by the user
System.out.print("Enter Total Number of Seconds :");
fromseconds=sc.nextInt();
//calling the method secondTime() by passing the seconds as arguments
String str=secondTime(fromseconds);
//Converting the string to String array where ',' is the delimeter
String arr[]=str.split(",");
//Converting the String into integer
hours=Integer.parseInt(arr[0]);
minutes=Integer.parseInt(arr[1]);
seconds=Integer.parseInt(arr[2]);
//calling the method inSeconds by passing the hours,minutes,seconds as arguments
toSeconds=inSeconds(hours,minutes,seconds);
//Displaying the hours,minutes,seconds to seconds
System.out.println(hours+" hours "+minutes+" minutes "+seconds+" seconds corresponds to
"+toSeconds+" seconds");
}
/*This method will converts the hours,minutes,seconds to seconds
* Params:hours,minutes,seconds
* Return:totalSeconds
*/
private static int inSeconds(int hours, int minutes, int seconds) {
//Converting the hours,minutes and seconds to totalseconds
int totSeconds=hours*3600+minutes*60+seconds;
return totSeconds;
}
/*This method will converts the seconds to hours,minutes,seconds
* Params:total Seconds
* Return:String
*/
private static String secondTime(int totseconds) {
//Declaring variable
int secs=totseconds;
//calculating the number of hours
int hours=totseconds/3600;
totseconds=totseconds-(hours*3600);
//calculating the number of minutes
int minutes=totseconds/60;
totseconds=totseconds-(minutes*60);
//Calculating the number of seconds
int seconds=totseconds;
//displaying the total seconds to hours,minutes,seconds
System.out.println(secs+" Seconds corresponds to "+hours+" hours "+minutes+" minutes
"+seconds+" seconds");
return hours+","+minutes+","+seconds;
}
}
_____________________________________________
Output:
Enter Total Number of Seconds :10000
10000 Seconds corresponds to 2 hours 46 minutes 40 seconds
2 hours 46 minutes 40 seconds corresponds to 10000 seconds
_____________________________________________
Output1:
Enter Total Number of Seconds :15000
15000 Seconds corresponds to 4 hours 10 minutes 0 seconds
4 hours 10 minutes 0 seconds corresponds to 15000 seconds
_________________________________________Thank You
Solution
ConvertingSeconds.java
import java.util.Scanner;
public class ConvertingSeconds {
public static void main(String[] args) {
//Declaring variables
int fromseconds,hours,minutes,seconds,toSeconds;
//Scanner class Object is used to read the inputs entered by the user
Scanner sc=new Scanner(System.in);
//getting the number of seconds entered by the user
System.out.print("Enter Total Number of Seconds :");
fromseconds=sc.nextInt();
//calling the method secondTime() by passing the seconds as arguments
String str=secondTime(fromseconds);
//Converting the string to String array where ',' is the delimeter
String arr[]=str.split(",");
//Converting the String into integer
hours=Integer.parseInt(arr[0]);
minutes=Integer.parseInt(arr[1]);
seconds=Integer.parseInt(arr[2]);
//calling the method inSeconds by passing the hours,minutes,seconds as arguments
toSeconds=inSeconds(hours,minutes,seconds);
//Displaying the hours,minutes,seconds to seconds
System.out.println(hours+" hours "+minutes+" minutes "+seconds+" seconds corresponds to
"+toSeconds+" seconds");
}
/*This method will converts the hours,minutes,seconds to seconds
* Params:hours,minutes,seconds
* Return:totalSeconds
*/
private static int inSeconds(int hours, int minutes, int seconds) {
//Converting the hours,minutes and seconds to totalseconds
int totSeconds=hours*3600+minutes*60+seconds;
return totSeconds;
}
/*This method will converts the seconds to hours,minutes,seconds
* Params:total Seconds
* Return:String
*/
private static String secondTime(int totseconds) {
//Declaring variable
int secs=totseconds;
//calculating the number of hours
int hours=totseconds/3600;
totseconds=totseconds-(hours*3600);
//calculating the number of minutes
int minutes=totseconds/60;
totseconds=totseconds-(minutes*60);
//Calculating the number of seconds
int seconds=totseconds;
//displaying the total seconds to hours,minutes,seconds
System.out.println(secs+" Seconds corresponds to "+hours+" hours "+minutes+" minutes
"+seconds+" seconds");
return hours+","+minutes+","+seconds;
}
}
_____________________________________________
Output:
Enter Total Number of Seconds :10000
10000 Seconds corresponds to 2 hours 46 minutes 40 seconds
2 hours 46 minutes 40 seconds corresponds to 10000 seconds
_____________________________________________
Output1:
Enter Total Number of Seconds :15000
15000 Seconds corresponds to 4 hours 10 minutes 0 seconds
4 hours 10 minutes 0 seconds corresponds to 15000 seconds
_________________________________________Thank You

More Related Content

Similar to ConvertingSeconds.javaimport java.util.Scanner;public class Conv.pdf

The java program Jumble that prompts user to enter nu.pdf
   The java program Jumble that prompts user to  enter nu.pdf   The java program Jumble that prompts user to  enter nu.pdf
The java program Jumble that prompts user to enter nu.pdfannapurnnatextailes
 
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfDigits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfannapurnnatextailes
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdfarshiartpalace
 
Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfarrowvisionoptics
 
Time.java public class Time {    private int hour; 0 - 2.pdf
 Time.java public class Time {    private int hour;  0 - 2.pdf Time.java public class Time {    private int hour;  0 - 2.pdf
Time.java public class Time {    private int hour; 0 - 2.pdfaniltulyani
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfarihantmum
 
array, function, pointer, pattern matching
array, function, pointer, pattern matchingarray, function, pointer, pattern matching
array, function, pointer, pattern matchingShakila Mahjabin
 
Clock.java public class Clock { 3 private ints to represent .pdf
Clock.java public class Clock { 3 private ints to represent .pdfClock.java public class Clock { 3 private ints to represent .pdf
Clock.java public class Clock { 3 private ints to represent .pdfanubhavnigam2608
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfFootageetoffe16
 
In JavaIn a 2D Arraya.)Display the row and column with the hig.pdf
In JavaIn a 2D Arraya.)Display the row and column with the hig.pdfIn JavaIn a 2D Arraya.)Display the row and column with the hig.pdf
In JavaIn a 2D Arraya.)Display the row and column with the hig.pdffeelingspaldi
 
Need to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdfNeed to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdfarchgeetsenterprises
 
Timers in Unix/Linux
Timers in Unix/LinuxTimers in Unix/Linux
Timers in Unix/Linuxgeeksrik
 
[SpLab3]Structures
[SpLab3]Structures[SpLab3]Structures
[SpLab3]StructuresNora Youssef
 
can someone fix the errors in this code- the name needs to be Fraction.pdf
can someone fix the errors in this code- the name needs to be Fraction.pdfcan someone fix the errors in this code- the name needs to be Fraction.pdf
can someone fix the errors in this code- the name needs to be Fraction.pdfvinaythemodel
 
Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++Yandex
 
Modify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdfModify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdfhullibergerr25980
 

Similar to ConvertingSeconds.javaimport java.util.Scanner;public class Conv.pdf (18)

The java program Jumble that prompts user to enter nu.pdf
   The java program Jumble that prompts user to  enter nu.pdf   The java program Jumble that prompts user to  enter nu.pdf
The java program Jumble that prompts user to enter nu.pdf
 
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfDigits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
 
Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdf
 
Time.java public class Time {    private int hour; 0 - 2.pdf
 Time.java public class Time {    private int hour;  0 - 2.pdf Time.java public class Time {    private int hour;  0 - 2.pdf
Time.java public class Time {    private int hour; 0 - 2.pdf
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
 
Vo.pdf
   Vo.pdf   Vo.pdf
Vo.pdf
 
Oop assignment 02
Oop assignment 02Oop assignment 02
Oop assignment 02
 
array, function, pointer, pattern matching
array, function, pointer, pattern matchingarray, function, pointer, pattern matching
array, function, pointer, pattern matching
 
Clock.java public class Clock { 3 private ints to represent .pdf
Clock.java public class Clock { 3 private ints to represent .pdfClock.java public class Clock { 3 private ints to represent .pdf
Clock.java public class Clock { 3 private ints to represent .pdf
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdf
 
In JavaIn a 2D Arraya.)Display the row and column with the hig.pdf
In JavaIn a 2D Arraya.)Display the row and column with the hig.pdfIn JavaIn a 2D Arraya.)Display the row and column with the hig.pdf
In JavaIn a 2D Arraya.)Display the row and column with the hig.pdf
 
Need to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdfNeed to revise working code below,A good design means the applicat.pdf
Need to revise working code below,A good design means the applicat.pdf
 
Timers in Unix/Linux
Timers in Unix/LinuxTimers in Unix/Linux
Timers in Unix/Linux
 
[SpLab3]Structures
[SpLab3]Structures[SpLab3]Structures
[SpLab3]Structures
 
can someone fix the errors in this code- the name needs to be Fraction.pdf
can someone fix the errors in this code- the name needs to be Fraction.pdfcan someone fix the errors in this code- the name needs to be Fraction.pdf
can someone fix the errors in this code- the name needs to be Fraction.pdf
 
Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++
 
Modify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdfModify your solution for PLP04 to allow the user to choose the shape.pdf
Modify your solution for PLP04 to allow the user to choose the shape.pdf
 

More from angelfashions02

N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf
                     N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf                     N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf
N= sp3 F = p orbital of F overlap with sp3 hybrid.pdfangelfashions02
 
I think you are missing an S species in the first.pdf
                     I think you are missing an S species in the first.pdf                     I think you are missing an S species in the first.pdf
I think you are missing an S species in the first.pdfangelfashions02
 
H2te , H2 Se, H2S , H2O .pdf
                     H2te , H2 Se, H2S , H2O                          .pdf                     H2te , H2 Se, H2S , H2O                          .pdf
H2te , H2 Se, H2S , H2O .pdfangelfashions02
 
Compound II and III only. .pdf
                     Compound II and III only.                        .pdf                     Compound II and III only.                        .pdf
Compound II and III only. .pdfangelfashions02
 
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdf
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdfUntil 2001, the 40-year-old Halamka also worked as an emergency room.pdf
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdfangelfashions02
 
The Final Accounts of non-trading concerns consists of1. Receipts.pdf
The Final Accounts of non-trading concerns consists of1. Receipts.pdfThe Final Accounts of non-trading concerns consists of1. Receipts.pdf
The Final Accounts of non-trading concerns consists of1. Receipts.pdfangelfashions02
 
sickel cell anemia is caused by recessive allele. frequency of sicke.pdf
sickel cell anemia is caused by recessive allele. frequency of sicke.pdfsickel cell anemia is caused by recessive allele. frequency of sicke.pdf
sickel cell anemia is caused by recessive allele. frequency of sicke.pdfangelfashions02
 
I think that (e) have only non-singular generalized inversesSol.pdf
I think that (e) have only non-singular generalized inversesSol.pdfI think that (e) have only non-singular generalized inversesSol.pdf
I think that (e) have only non-singular generalized inversesSol.pdfangelfashions02
 
Before Attempting to measure risk aversion, following two factors sh.pdf
Before Attempting to measure risk aversion, following two factors sh.pdfBefore Attempting to measure risk aversion, following two factors sh.pdf
Before Attempting to measure risk aversion, following two factors sh.pdfangelfashions02
 
Answer The general circumstance for retaining outside experts is wh.pdf
Answer The general circumstance for retaining outside experts is wh.pdfAnswer The general circumstance for retaining outside experts is wh.pdf
Answer The general circumstance for retaining outside experts is wh.pdfangelfashions02
 
AnsConsolidated financial statements are the aggregated or combin.pdf
AnsConsolidated financial statements are the aggregated or combin.pdfAnsConsolidated financial statements are the aggregated or combin.pdf
AnsConsolidated financial statements are the aggregated or combin.pdfangelfashions02
 
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdf
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdfAnswer b)S phaseS-phase is synthetic phase where semiconservative.pdf
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdfangelfashions02
 
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdf
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdfa)The NLS resides somewhere between amino acids 240 and 357. b)The.pdf
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdfangelfashions02
 
A database is generally used for storing related, structured data, w.pdf
A database is generally used for storing related, structured data, w.pdfA database is generally used for storing related, structured data, w.pdf
A database is generally used for storing related, structured data, w.pdfangelfashions02
 
9x^4y^10z^-2Solution9x^4y^10z^-2.pdf
9x^4y^10z^-2Solution9x^4y^10z^-2.pdf9x^4y^10z^-2Solution9x^4y^10z^-2.pdf
9x^4y^10z^-2Solution9x^4y^10z^-2.pdfangelfashions02
 
212+423 is same as 2 36+4 46 is same as 6 76 is same as 7 16...pdf
212+423 is same as 2 36+4 46 is same as 6 76 is same as 7 16...pdf212+423 is same as 2 36+4 46 is same as 6 76 is same as 7 16...pdf
212+423 is same as 2 36+4 46 is same as 6 76 is same as 7 16...pdfangelfashions02
 

More from angelfashions02 (20)

Phenol S.pdf
                     Phenol                                      S.pdf                     Phenol                                      S.pdf
Phenol S.pdf
 
N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf
                     N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf                     N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf
N= sp3 F = p orbital of F overlap with sp3 hybrid.pdf
 
isotopes .pdf
                     isotopes                                      .pdf                     isotopes                                      .pdf
isotopes .pdf
 
I think you are missing an S species in the first.pdf
                     I think you are missing an S species in the first.pdf                     I think you are missing an S species in the first.pdf
I think you are missing an S species in the first.pdf
 
H2te , H2 Se, H2S , H2O .pdf
                     H2te , H2 Se, H2S , H2O                          .pdf                     H2te , H2 Se, H2S , H2O                          .pdf
H2te , H2 Se, H2S , H2O .pdf
 
E=1 Solu.pdf
                     E=1                                      Solu.pdf                     E=1                                      Solu.pdf
E=1 Solu.pdf
 
Compound II and III only. .pdf
                     Compound II and III only.                        .pdf                     Compound II and III only.                        .pdf
Compound II and III only. .pdf
 
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdf
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdfUntil 2001, the 40-year-old Halamka also worked as an emergency room.pdf
Until 2001, the 40-year-old Halamka also worked as an emergency room.pdf
 
The Final Accounts of non-trading concerns consists of1. Receipts.pdf
The Final Accounts of non-trading concerns consists of1. Receipts.pdfThe Final Accounts of non-trading concerns consists of1. Receipts.pdf
The Final Accounts of non-trading concerns consists of1. Receipts.pdf
 
sickel cell anemia is caused by recessive allele. frequency of sicke.pdf
sickel cell anemia is caused by recessive allele. frequency of sicke.pdfsickel cell anemia is caused by recessive allele. frequency of sicke.pdf
sickel cell anemia is caused by recessive allele. frequency of sicke.pdf
 
I think that (e) have only non-singular generalized inversesSol.pdf
I think that (e) have only non-singular generalized inversesSol.pdfI think that (e) have only non-singular generalized inversesSol.pdf
I think that (e) have only non-singular generalized inversesSol.pdf
 
Before Attempting to measure risk aversion, following two factors sh.pdf
Before Attempting to measure risk aversion, following two factors sh.pdfBefore Attempting to measure risk aversion, following two factors sh.pdf
Before Attempting to measure risk aversion, following two factors sh.pdf
 
Answer The general circumstance for retaining outside experts is wh.pdf
Answer The general circumstance for retaining outside experts is wh.pdfAnswer The general circumstance for retaining outside experts is wh.pdf
Answer The general circumstance for retaining outside experts is wh.pdf
 
AnsConsolidated financial statements are the aggregated or combin.pdf
AnsConsolidated financial statements are the aggregated or combin.pdfAnsConsolidated financial statements are the aggregated or combin.pdf
AnsConsolidated financial statements are the aggregated or combin.pdf
 
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdf
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdfAnswer b)S phaseS-phase is synthetic phase where semiconservative.pdf
Answer b)S phaseS-phase is synthetic phase where semiconservative.pdf
 
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdf
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdfa)The NLS resides somewhere between amino acids 240 and 357. b)The.pdf
a)The NLS resides somewhere between amino acids 240 and 357. b)The.pdf
 
A database is generally used for storing related, structured data, w.pdf
A database is generally used for storing related, structured data, w.pdfA database is generally used for storing related, structured data, w.pdf
A database is generally used for storing related, structured data, w.pdf
 
9x^4y^10z^-2Solution9x^4y^10z^-2.pdf
9x^4y^10z^-2Solution9x^4y^10z^-2.pdf9x^4y^10z^-2Solution9x^4y^10z^-2.pdf
9x^4y^10z^-2Solution9x^4y^10z^-2.pdf
 
x= 38Solutionx= 38.pdf
x= 38Solutionx= 38.pdfx= 38Solutionx= 38.pdf
x= 38Solutionx= 38.pdf
 
212+423 is same as 2 36+4 46 is same as 6 76 is same as 7 16...pdf
212+423 is same as 2 36+4 46 is same as 6 76 is same as 7 16...pdf212+423 is same as 2 36+4 46 is same as 6 76 is same as 7 16...pdf
212+423 is same as 2 36+4 46 is same as 6 76 is same as 7 16...pdf
 

Recently uploaded

SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...Nguyen Thanh Tu Collection
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxMohamed Rizk Khodair
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 

Recently uploaded (20)

SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 

ConvertingSeconds.javaimport java.util.Scanner;public class Conv.pdf

  • 1. ConvertingSeconds.java import java.util.Scanner; public class ConvertingSeconds { public static void main(String[] args) { //Declaring variables int fromseconds,hours,minutes,seconds,toSeconds; //Scanner class Object is used to read the inputs entered by the user Scanner sc=new Scanner(System.in); //getting the number of seconds entered by the user System.out.print("Enter Total Number of Seconds :"); fromseconds=sc.nextInt(); //calling the method secondTime() by passing the seconds as arguments String str=secondTime(fromseconds); //Converting the string to String array where ',' is the delimeter String arr[]=str.split(","); //Converting the String into integer hours=Integer.parseInt(arr[0]); minutes=Integer.parseInt(arr[1]); seconds=Integer.parseInt(arr[2]); //calling the method inSeconds by passing the hours,minutes,seconds as arguments toSeconds=inSeconds(hours,minutes,seconds); //Displaying the hours,minutes,seconds to seconds System.out.println(hours+" hours "+minutes+" minutes "+seconds+" seconds corresponds to "+toSeconds+" seconds"); } /*This method will converts the hours,minutes,seconds to seconds * Params:hours,minutes,seconds
  • 2. * Return:totalSeconds */ private static int inSeconds(int hours, int minutes, int seconds) { //Converting the hours,minutes and seconds to totalseconds int totSeconds=hours*3600+minutes*60+seconds; return totSeconds; } /*This method will converts the seconds to hours,minutes,seconds * Params:total Seconds * Return:String */ private static String secondTime(int totseconds) { //Declaring variable int secs=totseconds; //calculating the number of hours int hours=totseconds/3600; totseconds=totseconds-(hours*3600); //calculating the number of minutes int minutes=totseconds/60; totseconds=totseconds-(minutes*60); //Calculating the number of seconds int seconds=totseconds; //displaying the total seconds to hours,minutes,seconds System.out.println(secs+" Seconds corresponds to "+hours+" hours "+minutes+" minutes "+seconds+" seconds"); return hours+","+minutes+","+seconds; } } _____________________________________________
  • 3. Output: Enter Total Number of Seconds :10000 10000 Seconds corresponds to 2 hours 46 minutes 40 seconds 2 hours 46 minutes 40 seconds corresponds to 10000 seconds _____________________________________________ Output1: Enter Total Number of Seconds :15000 15000 Seconds corresponds to 4 hours 10 minutes 0 seconds 4 hours 10 minutes 0 seconds corresponds to 15000 seconds _________________________________________Thank You Solution ConvertingSeconds.java import java.util.Scanner; public class ConvertingSeconds { public static void main(String[] args) { //Declaring variables int fromseconds,hours,minutes,seconds,toSeconds; //Scanner class Object is used to read the inputs entered by the user Scanner sc=new Scanner(System.in); //getting the number of seconds entered by the user System.out.print("Enter Total Number of Seconds :"); fromseconds=sc.nextInt(); //calling the method secondTime() by passing the seconds as arguments String str=secondTime(fromseconds); //Converting the string to String array where ',' is the delimeter String arr[]=str.split(","); //Converting the String into integer hours=Integer.parseInt(arr[0]);
  • 4. minutes=Integer.parseInt(arr[1]); seconds=Integer.parseInt(arr[2]); //calling the method inSeconds by passing the hours,minutes,seconds as arguments toSeconds=inSeconds(hours,minutes,seconds); //Displaying the hours,minutes,seconds to seconds System.out.println(hours+" hours "+minutes+" minutes "+seconds+" seconds corresponds to "+toSeconds+" seconds"); } /*This method will converts the hours,minutes,seconds to seconds * Params:hours,minutes,seconds * Return:totalSeconds */ private static int inSeconds(int hours, int minutes, int seconds) { //Converting the hours,minutes and seconds to totalseconds int totSeconds=hours*3600+minutes*60+seconds; return totSeconds; } /*This method will converts the seconds to hours,minutes,seconds * Params:total Seconds * Return:String */ private static String secondTime(int totseconds) { //Declaring variable int secs=totseconds; //calculating the number of hours int hours=totseconds/3600; totseconds=totseconds-(hours*3600); //calculating the number of minutes int minutes=totseconds/60; totseconds=totseconds-(minutes*60);
  • 5. //Calculating the number of seconds int seconds=totseconds; //displaying the total seconds to hours,minutes,seconds System.out.println(secs+" Seconds corresponds to "+hours+" hours "+minutes+" minutes "+seconds+" seconds"); return hours+","+minutes+","+seconds; } } _____________________________________________ Output: Enter Total Number of Seconds :10000 10000 Seconds corresponds to 2 hours 46 minutes 40 seconds 2 hours 46 minutes 40 seconds corresponds to 10000 seconds _____________________________________________ Output1: Enter Total Number of Seconds :15000 15000 Seconds corresponds to 4 hours 10 minutes 0 seconds 4 hours 10 minutes 0 seconds corresponds to 15000 seconds _________________________________________Thank You