|
|
|
|
Title: Java Programming Tutorial - 7 - Building a Basic Calculator
Added: May 3, 2009
Author: thenewboston
Duration: 7:12
Description:
How to build a basic calculator with the skills we have learned so far
Related Videos:
Videos related to 'Java Programming Tutorial - 7 - Building a Basic Calculator'
Channel: Howto
Tags: install download jdk se ee java development kit new beginner tutorials eclipse variables
install download jdk se ee java development kit new beginner tutorials eclipse variables
Youtube Comments: 1047
wowvorash Says:
May 8, 2012 - i have writen the code as seen in the video but at the row were the scanner is created i get error ';' is expected what do i do wrong
saveusjesus Says:
May 10, 2012 - i did this its exactly the same except the variablesi get no errors but it doesnt work
TerahawkZollo Says:
May 13, 2012 - It simply means that the compiler noticed that you missed a ';' at the end of the highlighted line.
jkgman1998 Says:
May 15, 2012 - mine works just fine you probably are having problems because it IS caps sensitive and some of the commands have to be uppercase
chengwm Says:
May 16, 2012 - you might get a proper reply if you actually explain what u're trying to do...
chengwm Says:
May 16, 2012 - use if(inc.equals("accept")) {*body*} instead. Strings can't be properly compared using == as with numbers.
LIINING Says:
May 16, 2012 - Ahh thank you very much!
unknownbillybob8077 Says:
May 16, 2012 - dear bucky, u are amazing at teachin u tot mehow to make lots of programs in java thank ukeep up good work :)
Tarn Williamson Says:
May 18, 2012 - I don't understand how the scanner applies 2 different values to 2 different variables. Surely it would need to scan a second time and set the next value to a different value, how can it give 1 value to one variable and a different value to a different variable? If fnum = bucky.nextDouble and so does snum, wouldn't the variables have the same value?
Sandy Schwartz Says:
May 22, 2012 - @wowvorash At the end of every command line, you need a semi colen.
AndyFarrell07 Says:
May 22, 2012 - No, fnum = bucky.nextDouble() prompts the user for a number and stores the value in fnum, then it does the exact same with snum = bucky.nextDouble(); the value of the variables will be what ever the user enters.
MetalGearSolidgaming Says:
May 23, 2012 - when i entered 34.6 i got the message: 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)Any idea what this means?
fraserMc96 Says:
May 23, 2012 - Is there a further lesson that shows how to create forms for the programs?
TheQuiksc0pe Says:
May 24, 2012 - How do i save something so i can run it?
RedFox134 Says:
May 25, 2012 - Something is wrong on line 8 of your program. Either there is a mis-spelling or the syntax is off for the Scanner variable "bucky". If YouTube lets you you could post your code in a comment and it would be easier to see what is wrong. There error message, while helpful with finding the error, doesn't show exactly what's wrong.
MetalGearSolidgaming Says:
May 25, 2012 - import java.util.Scanner;class apples{ public static void main(String args[]){ Scanner bucky = new Scanner(System.in); double fnum, snum, answer; System.out.println("Enter first num"); fnum = bucky.nextDouble(); System.out.println("Enter second num"); snum = bucky.nextDouble(); answer = fnum + snum; System.out.println(answer); }i still cant see whats wrong
sgtjgill Says:
May 26, 2012 - missing a curly brace at the end to close out the code
RedFox134 Says:
May 26, 2012 - I don't see an error either, and when I ran your code entering "34.6" for fnum and "1" for snum I get 35.6. Try running your program again and make sure you type "34.6". One of the times I ran your code I typed "34/6" instead of "34.6". That would cause you to get a "InputMismatchException".
MetalGearSolidgaming Says:
May 26, 2012 - i tried entering a number without decimal, it worked like that though
RedFox134 Says:
May 26, 2012 - I know sometimes something that helps me is to rewrite what I've typed. Sometimes it's a glitch in the program and there isn't anything you can do about it, but @sgtsgill pointed out that in your comment your are missing a "}" to close the "apples" class. You may have just missed it when you copy and pasted it into a comment, but that could cause an issue too. Sorry I couldn't have been of more help to you. Hopefully the later tutorial videos work out better for you! :)
Sickmanno1 Says:
May 27, 2012 - If you get error java.util.InputMismatchException, when imputing first number write with "," not ".", so for example, instead of writing 12.3, write 12,3.
MetalGearSolidgaming Says:
May 27, 2012 - well thanks for the help anyway
fafaerer Says:
May 27, 2012 - Basically, when you execute the class(in this example "apples"), it's the method that is automatically executed. Typically a project, of however many class has a main class that has this method, which initializes other classes, sort of like the brain of the operation.
dfsfklsj Says:
May 27, 2012 - Thanks, I'm already on his intermediate tutorials by now! XD












LIINING Says:
May 5, 2012 - Hey i tried to make so that u have to accept but it doesnt work.. System.out.println("Write accept to see the answear"); inc = krill.nextLine(); if(inc == "accept"){ System.out.println(answear); }maby some help? and i am a noob at java but i can make a calculator :P