Java Programming Tutorial – 7 – Building a Basic Calculator

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

22 responses to “Java Programming Tutorial – 7 – Building a Basic Calculator”

  1. Prashant Pawar Avatar

    Hi, I have an issue with the new version of Eclipse (Oxygen 4.7). I write java program and run but its nt running. some validation window is coming. pls hlp !!

  2. Reece McNeill Avatar

    Since the final answer is TOO BIG it would have to be 88.8* because the '0's would go on and on and on and never stop, the reason why there is a '1' there, is because it's a shortcut to the "end" of the sum.

  3. FactionsTazer Avatar

    Before I went to part 8 I added a class and added a subtraction to go along with it

  4. yukimal avatar Avatar

    Thanks you sooo much 🙂

  5. moeiz malik Avatar

    Can anyone please tell how to open this console ? i'm using notepad ++ and i'm not able to run any program i make.

  6. fweqfq fefwe Avatar

    since you can only run the program once, can someone teach me how run the calculator again?

  7. DatTrippinKitten Avatar

    What if you want to subtract? Would you put snum as a negative number? What about multiply and divide or is it not that advanced?

  8. PaperPlays HD Avatar

    When I type public static void main(String args []){ I get an error… Why does it do that? It started happening when i started episode 6

    This only happens in line 4, whatever I put in it. If I leave it blank it's an error, if I put anything in there it's an error.

  9. shadow girl Avatar

    what does ). next double( means. what does it do???????

  10. Ismaail Aatif Avatar

    PLEASE IF ANYONE CAN FIND WHAT WRONG WITH THIS
    package spoon;
    import java.util.Scanner;

    class Spoon {
    public static void main(String[] args) {
    Scanner input=new Scanner(System.in);
    double fnum,lnum,answer;
    System.out.println("enter your first number:" );
    fnum=input.nextDouble();
    System.out.println("enter your last number:" );
    lnum=input.nextDouble();
    answer=fnum+lnum;
    System.out.println(answer );
    }

    }

  11. mohamad allan Avatar

    I'm getting the word answer insted of the real answer what do I do wrong?

  12. Devi NS Avatar

    thankyou for the toturial is helping so much 🙂

  13. Akshar Joshi Avatar

    can we write answer.nextDouble()?

  14. Ghada mashally Avatar

    when I do the fnum + the snum as you did and then run it and write the first number and tap on enter, I get this:
    Exception in thread "main" java.util.InputMismatchException
    at java.util.Scanner.throwFor(Unknown Source)
    at java.util.Scanner.next(Unknown Source)
    at java.util.Scanner.nextDouble(Unknown Source)
    at apples.main(apples.java:8)
    What could the problem be ??

  15. Liam Welsh Avatar

    I'm brand new at programming java and I managed to make a better calculator just after watching this. It's just a couple extra System.Out statements but I think it's pretty cool I found this out by my self.

    package bucky;
    import java.util.Scanner;

    public class UserInput {
    public static void main (String[] args) {
    Scanner bucky = new Scanner(System.in);
    double fnum, snum, answer;
    System.out.println("Enter first Number");
    fnum = bucky.nextDouble();
    System.out.println("Enter second Number");
    snum = bucky.nextDouble();
    System.out.print(fnum);
    System.out.print(" + ");
    System.out.print(snum);
    answer = fnum + snum;
    System.out.print(" = ");
    System.out.println(answer);

    bucky.close();

    }

    }

  16. Hi everyone I'II watching you Avatar

    i learn so much about java programming on my campus but I'm not make that basic calculator before. this video improve my skills

  17. Pickquick Avatar

    Somehow i unfucked your code without even understanding it https://gyazo.com/01390594fee0f6a6499ace6c775ba4fe

  18. Hunter Zolomon Avatar

    Who would didlil this ? like wtf

  19. Bryan Avatar

    Everytime when i enter a double it gives me this error:

    "
    Exception in thread "main" java.util.InputMismatchException
    at java.util.Scanner.throwFor(Unknown Source)
    at java.util.Scanner.next(Unknown Source)
    at java.util.Scanner.nextDouble(Unknown Source)
    at me.bryan.javatest.Bryan.calc(Bryan.java:16)
    at me.bryan.javatest.Main.main(Main.java:8)
    "

    When i input an integer the calculator works fine.

    This is my code:

    "
    public void calc() {

    Scanner input = new Scanner(System.in);
    //
    double numOne;
    double numTwo;
    double answer;
    //
    System.out.print("Enter your first number: ");
    numOne = input.nextDouble();
    //
    System.out.print("Enter your second number: ");
    numTwo = input.nextDouble();
    //
    answer = numOne + numTwo;
    System.out.println("Your final answer is: " + answer);
    }
    }

    "

  20. Ove Games Avatar

    Exception in thread "main" java.util.InputMismatchException
    at java.util.Scanner.throwFor(Unknown Source)
    at java.util.Scanner.next(Unknown Source)
    at java.util.Scanner.nextDouble(Unknown Source)
    at Test.Test.main(Test.java:8)

Leave a Reply

Your email address will not be published. Required fields are marked *