Results 1 to 7 of 7
  1. #1
    romero is offline Member
    Join Date
    Apr 2017
    Posts
    3
    Rep Power
    0

    Default Help in simple java calculator

    Hello, basically I want to build a calculator with only one variable and some copy buttons. desktop application with this interface:
    Help in simple java calculator-programabtnt.jpg
    L is the only editable field
    is it any hard on netbeans? Thanks a lot.
    Last edited by romero; 04-30-2017 at 10:00 PM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Help in simple java calculator

    Quote Originally Posted by romero View Post
    is it any hard on netbeans?
    Not if you are familiar with NetBeans. But stay away from the GUI designer. It will only make your code hard to read and thus debug.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    romero is offline Member
    Join Date
    Apr 2017
    Posts
    3
    Rep Power
    0

    Default Re: Help in simple java calculator

    Quote Originally Posted by jim829 View Post
    Not if you are familiar with NetBeans. But stay away from the GUI designer. It will only make your code hard to read and thus debug.

    Regards,
    Jim
    Hello Jim, thanks for your answer.
    Well I had java classes at school, but I don't remember much, it's been a while. Do you think I'd better have someone do it for me? Thanks.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Help in simple java calculator

    Quote Originally Posted by romero View Post
    Do you think I'd better have someone do it for me? Thanks.
    What is the purpose of this? Clearly if you want to practice programming you have to do it yourself.
    Is it just to get a calculator? There are plenty of them to be had for free. So I am not really certain
    why you would ask that question.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    romero is offline Member
    Join Date
    Apr 2017
    Posts
    3
    Rep Power
    0

    Default Re: Help in simple java calculator

    Quote Originally Posted by jim829 View Post
    What is the purpose of this? Clearly if you want to practice programming you have to do it yourself.
    Is it just to get a calculator? There are plenty of them to be had for free. So I am not really certain
    why you would ask that question.

    Regards,
    Jim
    I'm not making any money with it, but it would help me do my job a bit faster with the copy buttons

  6. #6
    Nihar is offline Member
    Join Date
    May 2017
    Posts
    3
    Rep Power
    0

    Default Re: Help in simple java calculator

    Following is a simple Java Program which is a menu-driven program based on simple calculation like addition, subtraction, multiplication and division according to user's choice:

    /* Java Program Example - Make Calculator */

    import java.util.Scanner;

    public class JavaProgram
    {
    public static void main(String args[])
    {
    float a, b, res;
    char choice, ch;
    Scanner scan = new Scanner(System.in);

    do
    {
    System.out.print("1. Addition\n");
    System.out.print("2. Subtraction\n");
    System.out.print("3. Multiplication\n");
    System.out.print("4. Division\n");
    System.out.print("5. Exit\n\n");
    System.out.print("Enter Your Choice : ");
    choice = scan.next().charAt(0);
    switch(choice)
    {
    case '1' : System.out.print("Enter Two Number : ");
    a = scan.nextFloat();
    b = scan.nextFloat();
    res = a + b;
    System.out.print("Result = " + res);
    break;
    case '2' : System.out.print("Enter Two Number : ");
    a = scan.nextFloat();
    b = scan.nextFloat();
    res = a - b;
    System.out.print("Result = " + res);
    break;
    case '3' : System.out.print("Enter Two Number : ");
    a = scan.nextFloat();
    b = scan.nextFloat();
    res = a * b;
    System.out.print("Result = " + res);
    break;
    case '4' : System.out.print("Enter Two Number : ");
    a = scan.nextFloat();
    b = scan.nextFloat();
    res = a / b;
    System.out.print("Result = " + res);
    break;
    case '5' : System.exit(0);
    break;
    default : System.out.print("Wrong Choice!!!");
    break;
    }
    System.out.print("\n---------------------------------------\n");
    }while(choice != 5);
    }
    }

    Learn Java in tutorial form here: https://hackr.io/tutorials/learn-java
    When the above Java Program is compile and executed, it will produce the following output:
    Help in simple java calculator-java-program-make-calculator.jpg

  7. #7
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Help in simple java calculator

    Nihar, please don't spoonfeed solutions. It doesn't really help OP (original poster) them solve his/her problem. If someone
    wants to solicit for a solution to a problem then they can request it via the "Jobs Offered" forum on this site and discuss it out of band with the requester.

    Occasionally someone will ask for the actual code. Most of the time they want us to do their homework. That, we won't do

    Finally, when you do offer snippets of code to explain a concept, place them between code tags to preserve formatting. Check out BB codes below
    to read about .


    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Help with simple calculator?
    By Propinquity in forum New To Java
    Replies: 1
    Last Post: 10-09-2013, 02:41 PM
  2. Can't get this simple Calculator app to work!
    By postauma in forum New To Java
    Replies: 7
    Last Post: 02-18-2013, 08:50 AM
  3. Simple calculator
    By itaiyz97 in forum New To Java
    Replies: 2
    Last Post: 09-24-2012, 05:21 PM
  4. Help making a very simple calculator?
    By sfs in forum New To Java
    Replies: 2
    Last Post: 01-26-2012, 03:59 AM
  5. Simple Calculator
    By marksey07 in forum New To Java
    Replies: 12
    Last Post: 01-09-2011, 06:30 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
  •