Hey all,
i need some help with someone who knows a bit of java. Ive just started it in uni and having trouble getting a program to compile.
I need to make a program that can display 4220 seconds as hours:minutes:seconds and then skip a line then do the same for 2500seconds.
heres what i have so far:
/**
* Converts two different number of seconds to hours:minutes:seconds.
*
*/
public class TimeChanger
{
public static void main(String[] args)
{
int time = 4220;
int hours = time / 3600;
int hoursRemainder = time % 3600;
int minutes = hoursRemainder / 60;
int minutesRemainder = hoursRemainder % 60;
int seconds = minutesRemainder;
System.out.println(“4220 seconds:" +hours ":" +minutes ":" +seconds);
int time = 2500;
int hours = time / 3600;
int hoursRemainder = time % 3600;
int minutes = hoursRemainder / 60;
int minutesRemainder = hoursRemainder % 60;
int seconds = minutesRemainder;
System.out.println(“4220 seconds:" +hours ":" +minutes ":" +seconds);
}
}
im using blueJ as my editing tool and its coming up with an illegal character on the first print line.
any help would be much appreciated
who knows java?
- Carlman
- Staff Sergeant 2
- Posts: 1618
- Joined: Sat Nov 24, 2007 1:18 am
- Location: Western Australia
- Been thanked: 2 times
public class TimeChanger
{
public static void main(String[] args)
{
int time = 4220;
int hours = time / 3600;
int hoursRemainder = time % 3600;
int minutes = hoursRemainder / 60;
int minutesRemainder = hoursRemainder % 60;
int seconds = minutesRemainder;
System.out.println("4220 seconds: " +hours +":" +minutes +":" +seconds);
time = 2500;
hours = time / 3600;
hoursRemainder = time % 3600;
minutes = hoursRemainder / 60;
minutesRemainder = hoursRemainder % 60;
seconds = minutesRemainder;
System.out.println("2500 seconds: " +hours +":" +minutes +":" +seconds);
}
}
its all good i sorted it out in the end!
thanks to all who helped
lol jokes 
{
public static void main(String[] args)
{
int time = 4220;
int hours = time / 3600;
int hoursRemainder = time % 3600;
int minutes = hoursRemainder / 60;
int minutesRemainder = hoursRemainder % 60;
int seconds = minutesRemainder;
System.out.println("4220 seconds: " +hours +":" +minutes +":" +seconds);
time = 2500;
hours = time / 3600;
hoursRemainder = time % 3600;
minutes = hoursRemainder / 60;
minutesRemainder = hoursRemainder % 60;
seconds = minutesRemainder;
System.out.println("2500 seconds: " +hours +":" +minutes +":" +seconds);
}
}
its all good i sorted it out in the end!
thanks to all who helped



Aussie spudders unite!!
-
- Specialist 3
- Posts: 320
- Joined: Sat Dec 23, 2006 4:41 pm
- Location: Bend, Oregon
he just forgot a plus sign after hours and minutes.
This aint too hard, im doing if, while and for loops and i dont understand for loops too much but if and while arent really hard.
Now i know i can come to someone here if i need help
Now i know i can come to someone here if i need help

4SPC, My 4" piston 3" porting cannon
Memo:
Fix up copper cannon
Fix up 4SPC
Start Stirrup pump
Start Toolies piston bazooka
Memo:
Fix up copper cannon
Fix up 4SPC
Start Stirrup pump
Start Toolies piston bazooka
- Carlman
- Staff Sergeant 2
- Posts: 1618
- Joined: Sat Nov 24, 2007 1:18 am
- Location: Western Australia
- Been thanked: 2 times
yea the prob was i was defining the variables again which it didnt like and i foot to add the other parts of the string.
@ LikimysCrotchus5: I start loops today
@ LikimysCrotchus5: I start loops today


Aussie spudders unite!!
Well if you dont understand something, and i do, then give me a pm. We had the option of downloading jgrasp (java system and compiler i use) and i did so i can get some work done for school and also make programs to do math for me.
For example, i made a pythagorean theorem calculator that outputs the third side, instead of typing in a calculator. So it makes some work easier.
So if you want some programs for the hell of it, ill give you all the code.
P.S. For the keyboard reader, i usually give it a name besides reader, like Joe, makes programming sort of more fun
For example, i made a pythagorean theorem calculator that outputs the third side, instead of typing in a calculator. So it makes some work easier.
So if you want some programs for the hell of it, ill give you all the code.
P.S. For the keyboard reader, i usually give it a name besides reader, like Joe, makes programming sort of more fun

4SPC, My 4" piston 3" porting cannon
Memo:
Fix up copper cannon
Fix up 4SPC
Start Stirrup pump
Start Toolies piston bazooka
Memo:
Fix up copper cannon
Fix up 4SPC
Start Stirrup pump
Start Toolies piston bazooka
- Carlman
- Staff Sergeant 2
- Posts: 1618
- Joined: Sat Nov 24, 2007 1:18 am
- Location: Western Australia
- Been thanked: 2 times
how far along are you in java LMC?
ive had about 3 lectures on it
i use BlueJ, it was developed by a university in the eastern states of aussie land and is sponsored by sun microsystems. Its basically an easy to use system and compiler.
yea thanks foe the offer of help might take you up on it later
ive had about 3 lectures on it

i use BlueJ, it was developed by a university in the eastern states of aussie land and is sponsored by sun microsystems. Its basically an easy to use system and compiler.
yea thanks foe the offer of help might take you up on it later


Aussie spudders unite!!
Well i started this class in the beginning of my second semester so i have had almost 2 months i think.
I have this class for a semester so the farthest our teacher said we would get is to applets, which are like little internet advertizmetns, i think.
Yea and feel free to do pm me whenever, and your welcome
I have this class for a semester so the farthest our teacher said we would get is to applets, which are like little internet advertizmetns, i think.
Yea and feel free to do pm me whenever, and your welcome

4SPC, My 4" piston 3" porting cannon
Memo:
Fix up copper cannon
Fix up 4SPC
Start Stirrup pump
Start Toolies piston bazooka
Memo:
Fix up copper cannon
Fix up 4SPC
Start Stirrup pump
Start Toolies piston bazooka