Added: 2 years ago
From: thenewboston
Views: 360,853
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:
see all

All Comments (871)

Sign In or Sign Up now to post a comment!
  • Whenever I press "Run" in Eclipse, it doesn't do anything...HELP!!!

  • Apples ! :D

    

  • I made a pretty awesome text-based calculator from what bucky taught me: pastebin (dot) com/dUJxpei8

  • formulars?... do you have any tuts?

  • Enter first num; 10 Enter second num; 10 Enter third num; 5 Answer:15.0 Equation; 10.0 + 10.0 - 5.0 thats what I managed to do :p
  • I got an error saying " double cannot be dereferenced" when trying to run

    fnum.lucky.nextDouble();  ^

  • The error "Exception in thread "main" java.util.InputMismatchExcepti­on" is caused in my case by the input method for decimal separator. I changed it on my control panel and problem fixed. Before I would need to write 1,0 insted of 1.0 so when I wrote 1.0 I would get this error...

  • @PalmaIsrael I have the same problem...Any solution?

  • when do you tell the program to go to next number when you press enter?

  • never mind, figured it out. it works with a , not with a .

  • i get an error when i put in a deciaml number like 34.6;

    Exception in thread "main" java.util.InputMismatchExcepti­on at java.util.Scanner.throwFor(Unk­nown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextDouble(U­nknown Source) at Calculator.main(Calculator.jav­a:8)

    anyone know why?

  • I cannot enter a number with decimal point, such as 9.97..Help me!

  • I really need help on this one. My cursor selector in the editor is always on a word never inbetween them so if I make a mistake or need to add text it deletes the letters that were there to start with. This is getting really annoting please someone help me!

  • My claculator only does numbers without numbers behind the ,. i wrote it exactly like this but i still get an errormessage. what do i do?

  • if you want to show less decimals use this code after the first answer code :

    answer = Math.floor(answer * 100 + .5) / 100;

    Math is a class, in the lang package, that callz method floor that you use to round off the decimal points .

  • hey new boston,in this video you scan the number the user gives and store it in bucky,then you assign bucky to the other variables.What if you directly applied the number typed by the user,to the fnum and snum variables? Is this possible?or everytime the user inputs something the scanner variable automatically stores the new price and deletes the old one?

  • @4:41 you see it's 2:22 am, well he stays up late for us :) well thank you bucky

  • @55Briony i don't think the time is right because the date is the day after this was uploaded

  • thumbs up if pyropuncher brought u here

  • Pyropuncher <3

  • @iXaminez he teaches us to learn NOW LEARN

  • A little challenge:

    Try to make a calculator that can + - * and /

    I did it, and it's pretty easy ofc. But still a little funny challenge before you move on. I think it's good to make something yourself and not just write everything he does. I also changed the design of my calculator by making some in the same line, changing textcolor and size.

    Thumb up so ppl can get challenged!

  • @kakaofuglen1 hey can you tell me what can i do with java ? . Some examples of works. (I want to be app. developer ;) ).

    Thanks see ya

  • @kakaofuglen1 dude can you youst help me little bit. What if i don't know what's the code ? Is there any way to search like in Javascript officall website you youst write what you want and then it shows you the results what you need to write ...

    Thanks

  • @kakaofuglen1 hey i did your challenge all, but one part. How do you change the text color and size?

  • @TheLieutenantE That you can see in his previous tutorials. Unfortunately i'm also new to this, so i can't tell you what codes i used since i don't remember, but if you really wanna learn to, either search "how to" on google or look in his previous tutorials (:

  • @kakaofuglen1 k thanks

  • @kakaofuglen1 I got it on my first try, nice challenge :D

  • @RaptoJP How the hell did you change text color and text size? You probably already learned some java before.

  • @uratoko I didn't learn any Java before, I just experimented with the coding and got that.

  • @RaptoJP One does not simply get to know how to change text size and color by himself.

  • @kakaofuglen1 I can't seem to be able to add multiple actions :( Also are u sure He had font size ect. in an earlier video?

  • @HeavenlyBlade106 I figured it out; pastie(dot)org/3193023

  • @HALOzMODDER With help from a friend ^_^

  • @kakaofuglen1 Yes having trouble on multiple actions.

  • @kakaofuglen1 Yay I've done it! but I havn't got custom size and color :/

  • @kakaofuglen1

    Haha accepted the challange :p got it finished too. But I couldn't find a way to modify text size + color? Maybe he'll explain more later on

  • @kakaofuglen1 I made it plus if you write text, it says wrong input type, number excepted and if you divide by zero it says you can't divide by zero; and it restarts the program :)

  • Enter first Number:

    324

    Enter second Number:

    5235432432

    The answer is 5.235432756E9 you numnum!!!

  • import java.util.Scanner;

    public class Calculator { public static void main(String args[]){ Scanner Calc = new Scanner(System.in); double firstinput, Secinput, answer; System.out.println("Enter first Number: "); firstinput = Calc.nextDouble(); System.out.println("Enter second Number: "); Secinput = Calc.nextDouble(); answer = firstinput + Secinput; System.out.print("The answer is "); System.out.print(answer); System.out.print(" you numnum!!!"); }

    }

  • can any one help me I am getting this error when I type a float number (1.1 1.2 etc.):

    Exception in thread "main" java.util.InputMismatchExcepti­on at java.util.Scanner.throwFor(Unk­nown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextDouble(U­nknown Source) at tot_02.main(tot_02.java:13)

  • @TheJonkaa nvm I foud the problem

  • And I thought calculators were cleaver...

  • Remember, its , not .

  • does anyone know how to cancel those little widnows, like in 2:57? They're SERIOUSLY annoying =P

  • @ultislasher1 Click out of the window, into the text editor part.

  • @Theminecraftplayerdd do you know how to change it so that it never comes up again..? lol

  • @ultislasher1 There might be a way.

  • @Theminecraftplayerdd P.S. Merry Christmas/Hanukkah/Kwanzaa!!

  • I am le math experte :L

  • Comment removed

  • I've got the same problem as WiredDrummer,

    This is what it says:

    Enter your first number:

    3.14

    Exception in thread "main" java.util.InputMismatchExcepti­on at java.util.Scanner.throwFor(Unk­nown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextDouble(U­nknown Source)  at apples.main(apples.java:8)

    That line in my program states:

    fnum = bucky.nextDouble();

    Is that just what a Double variable can and cannot read? I'm using Eclipse Helios...

  • Is there anyway to change , to . ? If I use 3.14, it gives me an error, but if I use 3,14 theres no problem. Thanks for the tutorials, btw!

  • i think i like C++ better

  • killculator

  • Anyone here actually made any games or mods after watching from these tutorials? Wanna know if they work or not D:

  • helow! im realy thankful & appreciate for your video it helps me a lot as a 1st year BSIT student, but can i ask you something? as what you did in your video i think you just use only an operator addition adding two numbers,how about subtracting, dividing & multiplicating ..do you have a tutorial about it?..

  • Can anyone tell me how i can make it so you can choose + or -? i tried making a new variable, and making it so that the variable is the user input, but when it doesnt seem to work to well to just say "answer = fnum plusminus snum", which i can understand, but then how do i do it?

  • @SathApoc u have to use if. for example:

    if plus/minus = +: answer = fnum + snum

    if plus/minus = -: answer = fnum - snum

    im not an expert, but other python does this

  • @agcummings11 Ah! Thanks :)

  • I have done anything you did (word for word) and I get an error as soon as I enter first num that sais: 'Exception in thread "main" java.util.InputMismatchExcepti­on

    at java.util.Scanner.throwFor(Unk­nown Source)

    at java.util.Scanner.next(Unknown Source)

    at java.util.Scanner.nextDouble(U­nknown Source)

    at apples.main.(apples.java:8)'

    Please, help me!

  • @xetrius I've got the same problem, I just used "," instead of "." and it worked..:-P Give it a try..! Example: 34,2 instead of 34.2

  • @XmadBear27 Oke, thanks =D

  • @xetrius I had the same problem, you simply used the wrong separation point.

    Try using a "," instead of a "." when you write the input number:).

    So when you answer to "Enter your first number: " Write a number that doesn't have a dot in it:D

  • @xetrius try clicking Window>Open Perspective>Java

  • @xetrius I think you have a non-english windows and the character what separates numbers from decimals is not "." but "," (like for me, I'm from Hungary) So enter the first num as "34,6"( NOT as "34.6")

  • @karolyipeti thank you but @zorken123 already gave that answer

  • hey I am working in assginment what is the meth for char? exm: A = sc.nextChar(); ??! plz let me know

  • I learned alot so far but im just wondering, if you do the "if"and get a value that gose to "else" can i have the code inside the methods run another class?

  • 21 people dont know basic math

  • Comment removed

  • I just started learning Java... and I came up with things in this script I removed ln in printing first system out and the second and I added at the end ------ System.out.print("Your answer is: "); System.out.print(answer); System.out.println(" ."); ------ instead of --- System.out.println(answer);--- so it will print like: "Enter your first num: (here)" "Enter your sencond num: (here)" " Your answer is: (the answer here)." that's fun.
  • Ah, solved it:

    answer = fnum + (fnum* (snum * 0.01));

    so...computer asks "what's your number?" you type: 1.65, and it calculates 1.65 + 15% and gives you 1.89something...

  • I got it... answer = fnum +(fnum *(snum*0.01));

    this is for something like 1.65 + 15 %

  • the answer i get is 1.799999999

  • Got a glitch here, I think: I did all as you said, but want to write a formula that adds 15% to a value. Example: fnum = 1.65, and snum is 15%. It won't calulate correctly. Any hints?

    answer = fnum + (snum * 0.01);// having trouble writing 1.65 + snum%

  • @PhilmPhun Okay well you could do so you don't type in as a percentage.. but instead use a decimal system.. so yeah *0.01 but leave out when you input the % as % isn't a number xD wouldn't really work methinks?

  • How would make a users input string equal to a number? Like say the user types in "Cat" cat would be a int or a double but when i try that it says "Cannot be resolved to a variable". Anyone out there that can help me?

  • @TheThreeDarkAngels wait so what do you want it to do... type in cat and it comes up with 5? i need more info of what you want to do

  • @joeslayer97 Yea, Im trying to have it stored so i can use in later to calcuate a problem later on in the program. Ex: i want "cat" = 5. So when the user types in "cat" it knows that it has a value of 5. You get what im saying?

  • @TheThreeDarkAngels Try using an if statement such as this program:

    public class testcat{

    public static void main(String args[]) {

    Scanner input = new Scanner(System.in);

    char tessst;

    if(tessst == "cat")

    tessst = 5;

    }

    }

    Maybe it'll work..

  • @MrAetoc urmm you can't make test = cat... how about if the input is equal to cat then set firstnumber = 675432 or something?

  • @TheThreeDarkAngels You cant do it that way.. there is a way but the only thing i can remember is "char". its a variable that holds a character not a string.

  • @TheThreeDarkAngels

    import java.util.Scanner;

    public class StartingClass { private static double fnum = 0,snum = 0; public static void main(String[] args) { Scanner input = new Scanner(System.in); String bob = input.nextLine(); if(bob.equals("cat")){ fnum = 5; System.out.println("worked"); }else{ fnum = 3; } snum = input.nextDouble(); System.out.println(fnum+snum); }

    } try this :D i tested it out my self and works fine

  • @joeslayer97 Thanks joe, i will give it a try.

  • @TheThreeDarkAngels make a double named Cat, then make it equal whatever you want it to

  • @TheThreeDarkAngels This can be done with exceptions by using a try/catch clause.

  • @TheThreeDarkAngels

    Would this work?

    Cat = 5.2

    If that's what you meant...

  • @TheThreeDarkAngels Just make variables for each of the words i guess

  • @TheThreeDarkAngels i think i`t should be "variable = "thescannervariable".nextStrin­g();"

    sorry for the bad english xD

  • @WelberG3 I can't see that working. Maybe you mean " Var1 = Var2.Method/Function(Parameter­s); "

  • @TheThreeDarkAngels Are you insinuating that you're trying to save the string "cat" as an integer? That can't be done because integer means whole number (3.6 is NOT an integer, 4 and -2 are integers) and double, in this sense, means any number at all (-3, 3.6, 4, 0, etc.). Are you asking how to save a regular string as hexadecimal string for encryption? That is WAY beyond the level of this tutorial, encryption and obfuscation are some of the most advanced programming techniques out there.

  • @TheThreeDarkAngels you cant make an integer or double out of string

  • Comment removed

  • @TheThreeDarkAngels Uh, Maybe Variables Only Mean Integers (Numbers).

  • @TheThreeDarkAngels I think double is only decimals but idk... and Cat has to equal something to be used with int? I'm still very new to Java so idk lol

  • @prokid585 Yea me to, Decided to pickup a book and read lol

  • @TheThreeDarkAngels I have a book on Java. It's about 1400 pages lol but I find thenewboston's tuts easier than reading this book. The book I got is Ivor Horton's Beginning Java : Java 7 Edition. I've read almost 200 pages and done almost no coding at all lol.. I picked up this book today too xD

  • @TheThreeDarkAngels did you declare your variable at the top of your class?(int x; or int x = 5.28;)

  • @TheThreeDarkAngels ARe you trying to convert letters to their numerical values? Double and Int can only store numerical values, but you can (Don't remember how) convert from letters to numbers.

    If you mean changing a string to a # (as long as the string is a number :P) use ----- (integername) = Integer.parseInt(string name);

    or for a double ----- (doublename) = Double.parseDouble(string name);

  • @504Dug Thanks for the ideas

  • Comment removed

  • @TheThreeDarkAngels There other types of variables (I think so) that can withstand string variables. Int and Double are both numeral variables.

  • @TheThreeDarkAngels i did it :D

  • @BlahSer mine appears when I run the java code

  • I don't have the console on the bottom of my eclipse program. Anyone know what I'm doing wrong? Thank you!

  • I'm gettin it....My daughter provided the numbers. She says you sound like Lightning McQueen (Cars). :)

  • where do you get the scanner class from

    ?

    @thenewboston

    ??????????????

  • i have a problem. i cant seem to get the result. When i press the run button i don't get anything and all my code is right. CAN SOMEBODY HELP PLZ!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • I made a simple one where you can chose between +,-,* and /...

    and here's the source if you want it :D

    /zGQzSBW4 Add pastebin(.)com before :3

  • is here something like scanf as it is in c++?

  • I feel so smart, I knew what to write before he said it :D:D:D:D:D:D:D

  • @epicKiipa How old are you?

  • @zeusprp 15, why?

  • @epicKiipa Your channel says 55; & I thought that it's a little late to start leaning programming. :P

  • The best moment in my life!!!

  • this is addicting !!!

  • wow thanks so much!!!!!

    this is great i am actually getting hooked on this :D

    i keep on making the calculator!!!

  • THNx for this lttle help.. :)

  • Dude, thanks a lot!!!! You just helped me do my homework. I have make a program that will calculate the area and circumference of an ellipse

  • Non primitive "Scanner"......

  • which is better, BufferedReader or Scanner?

  • i need your help on my assigment. our instructor gave us a program wherein we will explain it line by line. please explain to me what's the use of this in my program..

    char type = in.nextLine().toUpperCase().to­CharArray()[0];

    below is complete syntax. please help me. thanks in advance!

    import java.util.Scanner;

    class weight1 {

    public static void main(String[] args){

    Scanner in = new Scanner(System.in);

    System.out.println("Enter pounds or ounce as your original unit of distance (P/O): ");

  • char type = in.nextLine().toUpperCase().to­CharArray()[0]; System.out.println("Enter your weight: "); double weight = in.nextDouble(); switch(type){ case 'P': System.out.println(weight + " pounds is " + (weight * 0.453592) + " in kilograms and " + ( weight * 453.59232)+ " in grams. "); break; case 'O': System.out.println(weight + " ounce is " + (weight * 0.02835) + " in kilograms and " + ( weight * 28.34952) + " in grams. "); break; } } }
  • god i am so hard right now

  • wow thanks im 10 and do java,javascript,and some ruby.

    this is the most advanced program i made and acually know what it means

    im hooked on java!

  • well mine cant plus numbers with like you know .6

    or .2

  • @lucas124l24 you have to type .oo

  • Umm dude, you made this video on May 3, 2009 at 2:22am(5:17) and you uploaded it on May 2. You can not only program great, you can time travel too!?

  • would this video help me make a social network site?

  • Great tutorial! again.

  • I created something exactly like this by accident after the previous tutorial as a little mess about xD

  • Import java.util.Scanner

    class poo{ public static void main(String args[]){ Scanner Ben = new scanner(System.in); }

    }

    That's all I can remember

  • @bvant6 after that you put:

    System.out.println(Ben.NextLin­e())

  • OMG "Scanner cannot be resolved to a type"

  • System.out.println("Answer: " + answer);

  • Didn't give me more than 2 decimals, and I followed it all exactly the same, lol. ;O

  • i came her to learn how 2 mc mod and now i cant STOP

  • @Game2Gaming give it a few years! you will not be able to do that until at least some experience!

  • You have to write 34,6 not 34.6 You have to use a comma

  • i did the same as you did but when i try to input a numbr like 34.6 it gives an error if i input 34 it doesnt. help?

  • @shaguarJNR try to type in 34,6 not 34.6

  • Crap didn't mean for that second post, can it be removed? And on top of that, can this one be removed?

  • System.out.println("Enter first number: ");  fnum = input.nextDouble();

  • I'm actually very fluent with flash and actionscript already. So I could probably skip a bunch of these. BUT! It's always best to look at everything so you don't miss anything.

  • Exception in thread "main" java.util.InputMismatchExcepti­on at java.util.Scanner.throwFor(Unk­nown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextDouble(U­nknown Source) at Start.main(Start.java:8)

    HELP!

  • @aVerb94 Use , instead of typing .

  • I made mine to do this

    User input: Hi!

    Java Program: Hi! *says under breath* God dammnit -_-

    XD

  • he said killculator XD

  • Comment removed

  • @theflumpster - You've probably typed the word 'Scanner' with the letter S in lower case! The words 'System & Scanner' in java should always be typed with the first letter S in upper case.

  • @theflumpster try java.util.Scanner;

  • i made a better calculator whit this tutorial that can do + - * / :D

  • You're getting fewer and fewer views for every episode xD

  • @Jshizzla Probably because some people give up so easily.

  • wow! Im getting the hang of this!

    I even added a small feature to this on my own, thanks!

  • does it matter if in:

    public static void main(String[] args) if the [] is after "String" or after "args" becuase I have used it both ways.

  • programmingandmore net

    Check out this site if you want to learn programming, hacking, webmaster, graphics and more!

  • i edited the script a bit to make it say "your answer is..." then the answer and i also made it say addition calculator wt the top lol

  • The method nextDouble() is undefined for the type Scanner

    WTF?

  • Check out our new programming forum:

    programmingandmore net

    Enjoy guys!

  • Java is for fags

  • @pomfan45 u sir are a fagdick

  • Comment removed

  • Please can someone help me?

    I am trying to make a quick program for minecraft that shows the id when you type in the block or item. But it doesnt work :S

    import java.util.Scanner;

    public class Class1 { public static void main (String args[]){ Scanner input = new Scanner (System.in); double stone; System.out.println ("Enter block/item:"); stone = input.nextDouble (); stone = 1; System.out.println (stone); }}

    I am a noob at java an this would be my first program. :)

  • @CnAxGaming

    That program should only print out the numder 1. If you remove the stone = 1; You would get the number you type in when you enter block/item. What is it you want the program to print out?