Compute the remainder of seconds entered by the user by the number of seconds
in an hour (SECONDS_X_MINUTE).
import java.util.Scanner;
public class Time {
public static final int SECONDS_X_HOUR = 3600;
public static final int SECONDS_X_MINUTE = 60;
public static final int AM_PERIOD = 43199;
public static void main(String[] args) {
int timeInSeconds;
int timeInHours;
int remainderHours;
int timeInMinutes;
int standardTimeInHours;
Scanner keyboard = new Scanner(System.in);
System.out.println ("Please Enter Time in Seconds :\t");
timeInSeconds = keyboard.nextInt();
timeInHours = timeInSeconds/SECONDS_X_HOUR;
remainderHours = timeInHours&SECONDS_X_HOUR;
timeInMinutes = remainderHours * SECONDS_X_MINUTE;
1. Divide the seconds entered by the user by the number of seconds in an hour
(SECONDS_X_HOUR), the result will be the hours in standard time.
5. The number of hours in AM/PM format is the remainder of dividing the hours in
standard time computed in (1) by 12.
again i think this might be a logic error on my part.
is this this what the problem is asking? if so my output is messed up.
int AmPmTimeInHours = (timeInSeconds%SECONDS_X_HOUR)/12;
Name:
Anonymous2009-02-08 19:34
i figured it out
int AmPmTimeInHours = timeInHours%12; its that right?
Name:
Anonymous2009-02-08 20:21
Do your own homework. Nothing you are being asked to do is hard, the majority of your errors are because you aren't even thinking about what you want to do, you are just writing statements. This isn't a "We'll write your programs" board.
Name:
Anonymous2009-02-08 21:12
will someone write a program doing the pythageron law for me plz?
>>30 int isqrt(n){
/* calculates integer square root. *
* if n is less than zero, calculates *
* integer square root divided by i. */
int r = 0, i = 1;
if(0 > n) n = -n;
for(i = i << ((sizeof(int) * CHAR_BIT - (0 > ~i ? 2 : 1)) / 2) * 2; i; i >>=2)
if(n >= (i | r)){
n -= i | r;
r = r >> 1 | i;
}else r >>= 1;
return r;
}
Name:
Anonymous2009-02-09 19:12
>>25,33 int i = sqrt(2);
float f = sqrt(2);
assert( (float) i == f);