can anyone help me please
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: can anyone help me please

  1. #1
    Join Date
    Jan 2013

    can anyone help me please

    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.out.print("Enter a number, 4 Digits long to recalculate the time!....");

    Total= time.nextInt();
    //hour = time.nextInt();
    //min = time.nextInt();
    //sec = time.nextInt();

    min = Total / 60;
    hour = min/60;
    sec = Total/60;

    int i = hour;
    int j = min;
    int h = sec;

    System.out.println("Hours equal " + i);
    System.out.println("Minutes equal " + j);
    System.out.println("Seconds equal " + h);

    int k = i % j;
    System.out.println("i%j is " + j + " minutes");


  2. #2
    Join Date
    Aug 2011
    West Yorkshire, U.K.

    Re: can anyone help me please

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


HTML5 Development Center