Page 1 of 1

who knows java?

Posted: Thu Mar 13, 2008 6:41 am
by Carlman
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

Posted: Thu Mar 13, 2008 9:35 am
by Carlman
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 :roll: lol jokes :D

Posted: Thu Mar 13, 2008 10:19 am
by dewey-1
--

Posted: Thu Mar 13, 2008 11:02 am
by jimmy101
So what was the error? The "smart quotes" in the println statements?

Posted: Thu Mar 13, 2008 11:08 am
by keep_it_real
he just forgot a plus sign after hours and minutes.

Posted: Thu Mar 13, 2008 2:02 pm
by SpudUke5
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 :)

Posted: Thu Mar 13, 2008 5:25 pm
by Carlman
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 :D

Posted: Thu Mar 13, 2008 5:42 pm
by SpudUke5
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 :D

Posted: Thu Mar 13, 2008 11:18 pm
by Carlman
how far along are you in java LMC?

ive had about 3 lectures on it :D

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 :wink:

Posted: Fri Mar 14, 2008 12:07 am
by SpudUke5
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 :)