Java Problem ... Converting seconds to mins, hours and so on...

P

PseudoKiller

Guest
#1
I am doing this extra credit project and I need some help. I am trying to convert 1 billion seconds into minutes, hours, days, weeks, months and years.
I am starting with seconds to minutes and below is what I have so far but I cant get it to work... any ideas??

Code:
[/color]
//SecondsToYears

[/color][/font][font=Courier New][color=#941edf]public[/color][/font][font=Courier New][color=#941edf]class[/color][/font][font=Courier New][color=#3c3c3c] SecondsToYears
{
[/color][/font][font=Courier New][color=#941edf]public[/color][/font][font=Courier New][color=#941edf]static[/color][/font][font=Courier New][color=#941edf]void[/color][/font][font=Courier New][color=#3c3c3c] main (String[] args)
{

[/color][/font][font=Courier New][color=#941edf]int[/color][/font][font=Courier New][color=#3c3c3c] sec, min, day, wks, mnths, yrs;
sec = 1000000000; [/color][/font][font=Courier New][color=#e69400]//this is how many seconds to convert
[/color][/font][font=Courier New][color=#3c3c3c]min = (sec / 60); [/color][/font][font=Courier New][color=#e69400]//first to minutes

[/color][/font][font=Courier New][color=#3c3c3c]System.out.print ([/color][/font][font=Courier New][color=#00cb00]"That's a lot of minutes "[/color][/font][font=Courier New][color=#3c3c3c] + min);


}[/color][/font][font=Courier New][color=#e69400]// eo main

[/color][/font][font=Courier New][color=#3c3c3c]}[/color][/font][font=Courier New][color=#e69400]//eo SecondsToYears [/color][/font]
 
P

PseudoKiller

Guest
#2
update... this is what I have so far

Code:
//SecondsToYears

public class SecondsToYears
{
	public static void main (String[] args)
		{

		int sec, min, day, wks, mnths, yrs;
		sec = 1000000000; //this is how many seconds to convert
		min = (sec / 60); //first to minutes
		day = (min / 24)); //To days
		wks = (day / 52); //To Weeks
		mnths = (wks / 30); //To Months
		yrs = (mnths / 12); //To Years
	
	System.out.print ("That's a lot of minutes " + min + "to be eact");
		
	System.out.print ("That's a lot of days " + day + "to be exact");
	
	System.out.print ("That's a lot of weeks " + wks + "to be exact");
		
	System.out.print ("That's a lot of months " + mnths + "to be exact");
	
	System.out.print ("That's a lot of years " + yrs + "to be exact");

		}// eo main

}//eo SecondsToYears
 

X-Istence

*
Political User
Joined
Dec 5, 2001
Messages
6,498
#3
Code:
//SecondsToYears

public class SecondsToYears
{
	public static void main (String[] args)
		{

		int sec, min, day, wks, mnths, yrs;
		sec = 1000000000; //this is how many seconds to convert
		min = (sec / 60); //first to minutes
		day = (min / 24); //To days
		wks = (day / 52); //To Weeks
		mnths = (wks / 30); //To Months
		yrs = (mnths / 12); //To Years
	
	System.out.print ("That's a lot of minutes " + min + "to be eact");
		
	System.out.print ("That's a lot of days " + day + "to be exact");
	
	System.out.print ("That's a lot of weeks " + wks + "to be exact");
		
	System.out.print ("That's a lot of months " + mnths + "to be exact");
	
	System.out.print ("That's a lot of years " + yrs + "to be exact");

		}// eo main

}//eo SecondsToYears
One to many )'s
 
P

PseudoKiller

Guest
#4
YEAH it works now... a little tweak here and a little tweak there, change the wording and voila...

Code:
[size=2]/SecondsToYears

public class SecondsToYears

{

public static void main (String[] args)

{

int sec, min, day, wks, mnths, yrs;

sec = 1000000000; //this is how many seconds to convert

min = (sec / 60); //first to minutes

day = (min / 24); //To days

wks = (day / 52); //To Weeks

mnths = (wks / 30); //To Months

yrs = (mnths / 12); //To Years



System.out.println ("1 Billion Seconds is approximately " + min + " minutes");



System.out.println ("1 Billion Seconds is approximately " + day + " days");



System.out.println ("1 Billion Seconds is approximately " + wks + " weeks");



System.out.println ("1 Billion Seconds is approximately " + mnths + " months");



System.out.println ("1 Billion Seconds is approximately " + yrs + " years");

}//eo main

}//eo SecondsToYears

[/size]
 

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Hey ep!

All good with me, applying for microsoft mvp right now, should have done this a while ago.

Notifications don't work, I only found your response by comming back to hunt up some threads, if you want, give me your email address so we can keep in touch easier, mine is perriscalderon at gmail
Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...

Forum statistics

Threads
62,027
Messages
673,527
Members
89,037
Latest member
MichaelPowers