Results 1 to 4 of 4
  1. #1
    Mahoo is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Question Simple Java BlueJ Converting Program

    Hey guys I'm new to Java and I'm having problems with it with the programming. I am trying to create a program to convert seconds to minutes to hours and grams to kilograms to metric tons. I can't find any good guides out there how to make a converting program for java blueJ and I was really hoping if anyone here could show me how to make a simple converting program.

    I was thinking about setting it up in a GUI but I really don't know how to. Could somebody please help? Thanks guys.

    Matt

  2. #2
    Mahoo is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default

    This is what code I gathered that I have a feeling I could re-write to use.

    Java Code:
    import java.io.*;
    
    public class FormatTime
    {
    
    public static void main(String[] args) 
    {
    
    //this will fetch our input values
    BufferedReader usrInput = new BufferedReader( new InputStreamReader( System.in) );
    
    System.out.println("Enter a number in seconds to format: ");
    int secs = usrInput.readLine();
    
    int hours = secs / 3600,
    remainder = secs % 3600,
    minutes = remainder / 60,
    seconds = remainder % 60; 
    
    string disHour = (hours < 10 ? "0" : "") + hours,
    disMinu = (minutes < 10 ? "0" : "") + minutes ,
    disSec = (seconds < 10 ? "0" : "") + seconds ;
    
    System.out.println(disHour +":"+ disMinu+":"+disSec);
    }
    
    }
    ______________________________________

    Still I am completely lost, please anyone help?
    Last edited by Eranga; 08-04-2010 at 05:27 AM. Reason: code tags added

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    What specifically is tripping you up? If it's that you don't know where to begin, then you will need to study the tutorials to learn the basics of the language first before you can program and should also have a look at this link which can help you to formalize your planning: Starting Writing a Program

    Luck!

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Simple Java program
    By Rolle in forum New To Java
    Replies: 3
    Last Post: 10-26-2009, 04:05 PM
  2. Converting simple Java Application to Applet
    By jrohde in forum Java Applets
    Replies: 1
    Last Post: 07-25-2009, 07:48 PM
  3. [SOLVED] Need help with simple Java program
    By hungdukie in forum New To Java
    Replies: 5
    Last Post: 11-26-2008, 03:17 AM
  4. help with simple program in java
    By katie in forum New To Java
    Replies: 2
    Last Post: 08-06-2007, 08:03 PM
  5. help with simple java program
    By leonard in forum New To Java
    Replies: 3
    Last Post: 07-30-2007, 09:40 AM

Posting Permissions

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