Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Calculator beginner tutorial(s)

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Calculator beginner tutorial(s)

    In my school course I need to present a calculator made in Java. The more complex, the better. However, I am a complete beginner. What tutorials for learning Java so you can make a pretty complex calculator would you recommend? I am not interested in learning things about Java that is not about calculators. That's why I'd like to see if there are some good tutorials that only, or at least mostly, are concerning how to learn making a complex calculator from the scratch.

    I have searched google but want to know if you have some great tutorials for this matter in mind.


  2. #2
    Member
    Join Date
    Apr 2012
    Posts
    160
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Default Re: Calculator beginner tutorial(s)

    Are you required to make a GUI or just perform actions from the console?

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Calculator beginner tutorial(s)

    No idea. All he's told me is to understand the codes of a calculator. The more complex, the better. Is it a big difference between what you mentioned?

    Edit: It's a beginner course of 50 hours. What would you expect one should know regarding calculators after 50 hours?
    Last edited by Mr.Greedy; June 13th, 2012 at 04:47 PM.

  4. #4
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Calculator beginner tutorial(s)

    Also at java-forums.

  5. The Following User Says Thank You to pbrockway2 For This Useful Post:

    copeg (June 13th, 2012)

  6. #5
    Member
    Join Date
    Jun 2012
    Location
    Left Coast, USA
    Posts
    451
    My Mood
    Mellow
    Thanks
    1
    Thanked 97 Times in 88 Posts

    Default Re: Calculator beginner tutorial(s)

    Quote Originally Posted by Mr.Greedy View Post
    ...What would you expect one should know regarding calculators after 50 hours?
    Perhaps a more important question (for some of us) would be "What would you expect one should know regarding Java after spending 50 hours in the classroom (or spending the on-line equivalent of 50 classroom hours) of a Java course?"

    The answer is, of course: "It depends." It depends on the reason that the course is offered in the first place, and it depends on the expectations of the instructor and it depends on the expectations of the "clients." (I hesitate to call them "students" until I know a little more about their collective agenda.)

    Anyhow, I don't usually like to do homework for people, but, being kind of new to Java, I used a search engine to look for Java Beginning Calculator Tutorials.

    Crap! Some of those things are hundreds and hundreds of lines long, and the ones with fewer than a thousand lines or so don't implement a very elaborate calculator. (A four-banger with square root in "only" 649 lines? Man, that's almost like work! That's not what we are here for, right?)

    So I tried to come up with the simplest Java program (one that requires what I consider an absolute minimal knowledge of Java) that implements a somewhat fancier calculator.

    So, as I said already, I don't usually like to do homework for others (not without getting paid), and I will probably get in trouble with Forum admins, but here is what I came up with:
    // A very small Java program for
    // a very elaborate calculator.
    //
    // For Linux systems you must have a
    // calculator program gcalctool.
    //
    // Execute "gcalctool" from a command line
    // to see whether you can expect success
    // from this program.
    //
    // If there is no such program, then RedHat
    // and Centos users can get it up and running
    // by executing the following from a command
    // line:
    //    sudo yum install gcalctool
    //
    // Then this little program is ready to run!
    // It's a Great, Great calculator.  Really!
    //
     
    // N.B.
    // Windows XP users probably have something
    // called calc.exe in their C:\Windows\system32
    // directory.  Try changing the name
    // in the exec() argument to calc.exe
    // or some such thing.  (I don't have
    // any way to test Windows stuff just now.)
    //
    // Zaphod_b
    //
    //
    import java.io.*;  // Gotta learn what this is all about.
     
    public class SysCmd  // Gotta learn what this is all about.
    { 
        public static void main(String [] args) // Gotta learn what this is all about.
        { 
            try // Gotta learn what this is all about
            {
                Process calc = Runtime.getRuntime().exec("gcalctool");  // Gotta learn what this is all about.
                calc.waitFor();  // Gotta learn what this is all about.
            }
            // In order to understand the following two, you have
            // to read up on exceptions. It is actually possible
            // to make the "catch" stuff actually do something
            // meaningful, but since that has nothing to do with
            // calculators, why bother?  Just leave them empty
            // for now.
            //
            catch(IOException e){}
            catch(InterruptedException e){}
     
            System.out.println("Tttttthat's all, Folks!"); // Indicate normal exit from the above stuff
        } 
    }

    (Copy it quick! They may take it down and impose a lifetime ban yours truly at any moment.)

    Something like nine lines of Java, not counting the {} braces. (Doesn't really need the parting message, but I always like to put in something to indicate a normal exit from a program.)


    Cheers!

    Z
    Last edited by Zaphod_b; June 13th, 2012 at 06:04 PM.

Similar Threads

  1. Need Beginner Calculator Program help!
    By theJastro in forum What's Wrong With My Code?
    Replies: 18
    Last Post: December 17th, 2011, 07:30 PM
  2. Replies: 1
    Last Post: November 11th, 2011, 07:46 PM
  3. CMD-Like GUI Tutorial
    By lucienmontierre in forum Java Theory & Questions
    Replies: 2
    Last Post: April 18th, 2011, 02:17 PM
  4. Good Beginner AWT tutorial
    By helloworld922 in forum AWT / Java Swing
    Replies: 2
    Last Post: August 4th, 2009, 10:31 AM
  5. Store data in database using JSP
    By abhi4jdk in forum Java Servlet
    Replies: 1
    Last Post: May 18th, 2009, 04:42 AM