I need to use the modulous operator on this program. can anyone steer me in the correct direction. I am new to Java and I am trying to understand this language. Please help, my code is as follows
import java.util.Scanner;
public class Remainder {
public static void main (String args[]) {
int hour, min, sec, Total;
Scanner time = new Scanner(System.in);
System.out.print("Enter a number, 4 Digits long to recalculate the time!....");
I'm guessing your input is a number of seconds .... so calculating hours is easy:
int hours = Total / 3600;
Minutes is where you need the modulus operator ... and divide the result by 60:
int mins = (Total % 3600) / 60;
And finally, seconds ... just divide by 60 as you have it.
Bookmarks