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

Link to this comment:

Share to:
see all

All Comments (312)

Sign In or Sign Up now to post a comment!
  • who is learning Java to make android apps?

  • Comment removed

  • Wouldn't you have to use double average or divide by 10.0 because the average from 1 to 10 is 5.5?, or did you purposely round down due to it being grades? , I'm from the UK so e don't have GPA's

  • @bham6666 You don't have to use int. I am using doubles. He is just doing what he think is the easiest for us. I am for instance using a Scanner to input how many grades i have. That means that i have another Int called "many". So when i am writing the While loop, i am typing "while(counter < many)" and then the rest.

    At the bottom of the code i am writing average = total / many;

    Hope this helped you. Short answer: He just want to make the tutorials "easy" :)

  • Cya Latel

  • @DevilOnHog it actally can take any numbers that are ints becuase it adds to grade and total not the counter.The counter is the only thing that has to be less than 10

  • you can simply put (counter++ > 10) in the while loop.

  • It would be nice to have on these videos an input check,say that the user puts 72 instead of a number from 1-10,so that it should have a message displayed "Wrong grade inserted" and should start the scanning once more...input checking might be the single most important thing that connects the user with the program itself

  • static void Averagegrade(){ int counter = 0; int total=0; int sum; int average; int position = 1; Scanner scan = new Scanner(System.in); System.out.println("How many subjects do you have?: "); int numSub = scan.nextInt(); while (counter < numSub){ System.out.println("Enter your grade for subject number "+position+"."); position++; sum = scan.nextInt(); total = total + sum; counter++; } average = total/numSub; System.out.println("Your average grade is: "+average);

  • lol!!!!at last i have understand tis code,why he ned counter and why it wil let u input for 10 times......

  • can anyone explain to me abot the counter part??

  • Can someone please explain to me what static, new & return all mean and do? I just need to know what they do because they are what is confusing me

  • I actually got this one!!!

  • I'm having problems, when I try to run it, it says that it can't find main class.

  • @admirnaruto Perhaps you forgot the "public static void main (String[] args)" line?

  • @Insomniac10102 No I fixed the problem eclipse was giving me some problems.

  • the average of 1 trough 10 is 10...

  • Why do i get a warning at the 4th line? It says, I have to use (final String[] args)?

    Oh and why do I get pop-up when I write [] after String?

  • How can I modify this to have an undefined number of numbers? Maybe with if commands, where a "yes is triggered by a certain word?

  • Who's learning this NOT to mod minecraft

  • @williamsc Heh, this is over kill compared to modding minecraft :P I learned modding in about 1 day :/ now I wanna learn real java before I start at my school as it would make life easier.

  • @williamsc ME! :D

  • @williamsc I'm learning this to make my OWN minecraft :D

  • @williamsc I'm just learning this to someday make my own 2D games. I've honestly never cared for making 3D games.

  • @williamsc Well, I'm learning this because of Minecraft, and I want to be able to make Minecraft mods, but I REALLY want to learn this so that I can make a cool game.

  • You used to use the square brackets after the args like this (String args[]) and now you're doing it (String[] args) instead, what's the difference?

  • @Justoneofthebrothers If u watched his starting tutorial(s) he said it doesnt really matter where u put those"[]". So u can put them before "args" or after "args"

  • @MrShubby12 Thank you mate :)

  • there's no difference man :)

  • you can just set grade to 0 and do "grade = grade + input.nextInt();". Then dont need four varibles, only three

  • thank you , i love bucky!!!!!

  • 3:14 KKK?!

  • {O;O}

    --( )--

     / \

  • public static void main(Thank[]you);

    :))

  • bucky's videos take ten days to upload because they have to process all the awesomeness. He started uploading the video on May 1, 2009

  • damn, I always forget to click like on his videos. I think this is the first one I clicked...

  • I just can't thank you enough! God bless!

  • //part 2//

    amount = input.nextInt(); System.out.println ("Please add the numbers you wish to be averaged"); while (counter <amount){ grade = input.nextInt(); total = total + grade; counter ++; } average = total/amount; System.out.println("Your average is "+average); }

    }

  • //part 1//

    import java.util.Scanner;

    class YouAreDoingItForGames { public static void main (String args[]){ Scanner input = new Scanner(System.in); int total =0; int grade; int average; int counter = 0; int amount; System.out.println("How many things do you want to average?");

  • Edited the formula to include a user input that allows the user to decide the amount of things that should be averaged (As most teachers got a different amount of pupils, and therefore also a different amount of grades, this is extremely useful) ^^

    Will be posting it shortly,

  • Casting needed.

    average = (float)total/10;

    so you can get 5.5 instead of 5. (55/10=5.5)

  • @3:12 C-C-C-Counter Breaker!

  • While(Bucky == AWESOME){

    System.out.println("You sir, are very awesome.");

    }

  • Bucky...dude..you rock maan..Thank u...

  • I used "total += grade;" which also works

  • And I thought my teachers were useless idiotic bastards .. but it seems like everyone around are complaining of there's too

  • @q2828q Int and Double are numeric values, but a string consists of words "This is a string"

  • very nice tutorial, lol! Much better than my teachers :)

  • i dont really understand what strings are can someone please explain them to me :( i would greatly appreciate it!

  • 21 videos in a row, gotta piss.

  • thanks for all of the great tutorials (i've got many more to watch!) could you show how to export these class files so you can run it as a program outside of eclipse? if this if very simple then can somebody just comment, if not thanks! P.S. Im very new to programming :D

  • @Slugshot177 See tutorials 1 & 2

  • great tutorials, this one has a slight flaw, the counter var is not nec

  • Uhm.. the average of 1 through 10 = 5,5

    So maybe wanna make the average a double ;)

    Cheers!

  • thanks ur realy helping us

  • Thumbs up if you are NOT at this video on the first night, if you you actually write some of the programs, if you add more code to the program and try out things, and if you don't forget half the stuff he teaches you when you wake up the next morning.

  • how might you let the user choose how many numbers to average? would you add another int than make the average = total/ that other int?????

  • What's the difference between total += grade and total =+ grade, because I first did += and got 1, with number 1-10, then did =+ and got 5, like you did.

  • @cplusplusgamer used total+=grade; and got 5...

  • @cplusplusgamer

    this is because there is an acutal symbol which is +=.

    so total += grade; is adding the value of grade to whatever is total already.

    so total =+ grade; is basically total = grade; which assigns the value of grade to variable name "total"

    so when you run it. the last number will always be the total.

    total = 10, avg = total/10 = 1.

  • System.out.println("WE LOVE YOU BUCKY");

  • 1+2=3 3+3=6 6+4=10 10+5=15 15+6=21 21+7=28 28+8=36 36+9=45 45+10=55 55/10=5.5 did i missed somthing,
  • @emmeran123

    a few tutorials before this one, he shows what happend in this case. 55/10 is 5.5 but int cant present float or double.

    Excuse me for my bad english..im german^^

  • @emmeran123

    i tested it..but i htink im wrong...

    i used 4 floats an the erg was 5.0...

    now i want to know why the erg is wrong and i think it is the loop..

    If u give java 2 floats an set the first 55 and the second 10 the erg of 55/10 is 5.5, but in the loop the erg is 5.0

  • It works with floats...i used the counter to divide..but if u use the counter you divide by 11 not by 10..use floats and divide by 10 and your average is 5.5

  • 2:50 I'm not asking why don't you put {total = grade} I'm asking why you don't put {total += grade} ? =P

  • Made a dutch version which asks How many grades you have, and then says: Grade 1: , Grade 2: etc until the right amount is reached. Had to make 2 more ints and a new if-statement.

  • Tweaked so you can imput how many grades u want to average every time. =D

  • My schedule, wake up, goto school, come home, play minecraft, do homework, ten lessons of java. <3 bucky

  • Thumbs up if you already knew everything up to this video on the first night, and it's all just a review for you. (A good review, though =D)

  • import java.util.Scanner;

    public class apples { public static void main(String[] args) { Scanner input = new Scanner(System.in); int total = 0; int counter = 0; int grade; double average; do{ System.out.println("Please enter a Grade(Enter '0' to calculate):"); grade = input.nextInt(); total = grade + total; counter++; }while (grade != 0); counter--; average = total / counter; System.out.printf("The average of the " + counter + " students is " + average);

  • Bucky, You are the best java teacher there is. You taught a 10 year old (Me) basoc java on 5 days. 5 DAYS! I never got lost, I never stubbed off. You are awesome.

    if (Bucky == awesome){

    System.out.println("Thank you tons!");

    int rating = 10;

    System.out.print("My rating of you is");

    System.out.print(rating);

    System.out.println("Out of 10.);

  • Damn it why cant I learn this at school and only this?

  • after you made the while loop, i paused and managed to make the rest of the program thanks to what you taught me before. Thank you, you are amazing, i think that you should get millions of views like certain videos. seriously, i knew NOTHING about java before and my friend says at this rate ill master java in 2 days.

    if(bucky == awesome){

    System.out.println("thank you!");

    }

    > thank you!

  • who is learning this to mod minecraft :F

  • @xero907 me :D

  • I'm at this video, after learning XTML, CSS, Javascript and PHP, it's the third day. After making this program, I decided to experiment with the program, it now asks you how many grades you would like to input first, before running the while loop, so then you can put in however many grades you like :) Thanks Bucky, I've learned more programming in 3 days than I have in all of the books I read over the past year.

  • great tutorial, just one comment is that the variables should be doubles because the actual average is 5.5 and not 5...

    thanks a lot for the tutorials anyway man, they're great!!

  • @tal11333 I agree totally with you

  • right now i was like= "get going youtube downloader"..".faster!!!!":)

  • I just made a program in portuguese that sums 10 numbers! int n_temporário; int cronômetro = 0; int soma = 0; while (cronômetro < 10){ n_temporário = input.nextInt(); soma = soma + n_temporário; cronômetro++; }

  • Beautiful! :D

  • 0:47-0:50 sounds like he's singing.

  • average = total/counter would be better :P

  • Notch learned from Bucky

    I'm learning from Bucky

    I'm gonna be the next NOTCH!

  • @IWolfGod how did you know that notch learned from Bucky...if thats true

  • @IWolfGod notch didnt learn from bucky

    

  • @IWolfGod no he didn't. but you can certainly code as fast and as brilliant as notch if you really work hard for a LONG time. good luck! (youll need more than bucky's tutorials, go buy some java books, if anything, just as a reference tool until you memorize the language from experience).

  • Finally, he uses the stuff he taught us to make an interesting "program". Good job!

  • I would like to thank you for inspiring me. I am on this episode, been watching 10 of your videos a night. Slowly learning Java, at a wonderful pace. Your a very good teacher. I wish that you could teach at my school, because we don't do programming there. (Sadface)

    System.out.println("Thank you for, all your help!")

  • @Camczad258 you frogot the semicolon man ;)

  • @ItzTheFury Damit, you know, as soon as I pressed post, I realized that within the next month, someone would say that I forgot the semicolon :D lol

  • @Camczad258 My school does programming... After 4 weeks... We still haven't even done a If statement, all we have done is System.out.println("HELLO WORLD!") ... Not even int or double to do something like

    int age = 30

    System.out.println("You are" age);

    System.out.print("years old!");

    Your not missing out on anything trust me.

  • @Camczad258 Forgot the semicolon ;)

  • @Camczad258 Wheres the semicolon?

  • @Camczad258 He inspires you yet you forget the semi-colon at the end of your print statement? :( ;)

  • @Camczad258 lol, you forgot to put the ' ; ' at the end

  • @Camczad258 you forgot to end your statment with a semicolon

  • @Camczad258 where is ;? :)

  • @Camczad258 LOL you forgot the ";" at the end :P

  • @Camczad258 you forgot the semicolon.

  • @Camczad258 if(Your school < Tech school){  System.out.println("Transfer schools");

    Unless ur like me and ur parents won't let u do that *sadface

  • Well the last top comment a few vids ago seemed to say that he was the only minecrafter left, I AM STILL HERE!!!

  • inputed...

    *twitches*

  • Bucky, question, on line 13 could we have: total +=grade;

    I remember in a previous tutorial you showed us to add grade to total with less typing?

  • Comment removed

  • Why can't I put in so many numbers as I want?? like 44444444444 and 888888888

  • @superdatamaskin Because int has a capacity of 32 bits. That means that you can only enter numbers from around -2000000000 to around 2000000000. In C++ you use long long if you want to have more space (64 bits instead of 32) but in Java I don't really know.

  • @WannabeTheAwesomest

    Thanks dude :)

  • @superdatamaskin No problem :D

  • my question ïs; why always useing "int" when "double" gives you more precise answers?

  • @superdatamaskin I did the math and 55/10=5.5 since int only gives whole numbers, the average is output as 5, if we were using double, then I believe we would get the decimal value as well.

  • 2:38 but what if I want to average it lato? Nice vids btw. Somehow addictive

  • If you wish to take user input....then...COPY!!

    import java.util.Scanner;

    public class another {public static void main(String[] args){Scanner input = new Scanner(System.in);double total=0,grade,avg,n,counter=0;­System.out.println("Of how many numbers do you wish to calculate the average? : \n");n=input.nextDouble();Syst­em.out.println("Begin entering numbers: \n");while(counter<n){grade=in­put.nextDouble();total=total+g­rade;counter++;}avg=total/10;S­ystem.out.println("Your Average is "+avg);}}

  • @carrots087

    thanks man

    now i see my mistake ;)

  • import java.util.Scanner;

    class apples{ public static void main(String args[]){ Scanner input = new Scanner(System.in); double total = 0; double grade; double average; double counter = 0; while(counter < 10){ grade = input.nextInt(); total = total + grade; counter++; } average = total/10; System.out.println("Your average is " + average); }

    }

    try this code guys, it gives a decimal for more accurate %

  •  while (counter>10){ grade = input.nextInt(); total+= grade; counter++;

    }

    why it dosent wait for my input

    any time i start the program it says "your average is 0"

    can somebody pleas show me the mistake

  • @ZebrAHeaD010

    type this exact code:

    import java.util.Scanner;

    class apples{ public static void main(String args[]){ Scanner input = new Scanner(System.in); double total = 0; double grade; double average; double counter = 0; while(counter < 10){ grade = input.nextInt(); total = total + grade; counter++; } average = total/10; System.out.println("Your average is " + average); }

    }

    you can change double to int, but it works, compare it to your

  • @ZebrAHeaD010 Gimme your complete code...

  • while (counter>10){ grade = input.nextInt(); total+= grade; counter++;

    }

    why it dosent wait for my input

    any time i start the program it says "your average is 0"

    can somebody pleas show me the mistake

  • i get an error with:

    grade = input.nextInt();

  • @RealMinecraftTV must be "nextInt" no "nextint"

  • @iiwudaffk I have it as nextInt. but I found the problem. It had something to do with the method. I think I put (System[] args){

  • @RealMinecraftTV

    Reply me your code...I will try to resolve it...Ty..:)

  • @Deathangelhj I actually fixed it haha.. and I made a new workspace with mcp for minecraft anyway lol

  • Yea Im gonna have to give up.. This is getting way too confusing for me :( Though I wish I could learn it if I understood.

  • @TheLimify it takes time for it to soak in

  • @TheLimify Practice every tutorial 3 times, take screen shots of the finished script after every tutorial, and save every term or important piece of info with a definition in notepad, then achieve :P

  • i called my average double but i still dont get decimal averages. why is that

  • Thumbs up if you're at this video already on the first night.

  • @HarrowedBeThyName if i started at 9 pm yesterday, and it is 9 am right now does that count

  • @HarrowedBeThyName i got up to tutorial 42 :) im going through them again so i can remember them better

  • @HarrowedBeThyName Dude this was my school day x)

  • You can hav it as that but he was just showing us the average command and refreshing our memory

  • Shouldn't grade and average be double? And grade = input.nextDouble();? The average of 1-10 is 5.5.

  • @MrSkateify If you wanted to input decimal numbers and/or get a more accurate average, then yes.

  • I'm making notes on what you say in these videos... In Java

  • I love the way you pronounce the word "scanner". Everytime you say it I laugh.

  • And to think I used to think java was a kind of coffee.

  • @AMVfanatic1081 AND an island ;)

  • I made a more advanced one that actually gets your input of how many numbers you want and then you enter that many numbers, I probally might post a link to it but now now.

  • @Proxymous Haha, i did the EXACT same thing! XD

  • For whatever reason, Java makes more sense than Objective-C to me. Hopefully this will give me an advantage in AP Computer Science next year!

  • I love this guy

    

  • Why did he set the int total = 0? Makes no sense

  • @SargentSpecs because total is 0 before any grades are added to it

  • i added a howmany var that the users defines and made it while(counter < howmany);

    so that they choose how many digits they use and it still gets correct average cuz

    average = total / howmany

  • Rate this comment if you're less than 30 & wanna be the next notch xD

  • total supposed to divided by counter not 10 ! i mean average=total/counter.

    great tutorials!thanks a lot!

  • @tolquito technically it should be

    average = total/counter--

    otherwise you get one too many in the counter

  • @lpminecraftvideos No cuz you do counter++ before the loop fails so counter is 10 afterwards

  • Can anyone tell me that why scanner input is not inner of the while loop?

    Does it scan everytime we type on the console?

  • @ptchau2003 "Scanner input = new Scanner(System.in)" is just initializing the Scanner. Console waits for your input every time you call the method "input.nextInt()" which is in the loop .

  • @finroid : Thank you very much. I got it.

  • @ptchau2003 Scanner input sets up the variable "input" to store key board input. grade = input.nextInt(); is where the scanner is being utilized and is in the while loop. It says, look for the next int input from the keyboard and store it in the variable grade.

  • no output for me

  • I think you can also write:

    "grade = grade + input.nextDouble();"

    instead total

    in my opinion is my way easier but yours is not bad too.

  • I DONT WANNA BE A TEACHER!!!

  • howcome whenever i do something and it spells it out it will do somethint like your average is5

  • @BrandonCpatrick because you are forgetting to add a space after the word "is" in your print statement. ("Your average is "+ average). The space must be between the word "is" and the final quotation.

  • someone help!!! why do i get this error with the public static void main (String[] args) {

    line java.lang.NoSuchMethodError: main

    Exception in thread "main" ?!?!?!?! and else does not work for me if i do }else{ it gives me error if i just do else also gives me a error

  • Amazing videos, these make JAVA simple!

  • Hehehe, my program's better than your's. I made mine so you can put as many numbers as you want, then when you are done and want the average, you hit enter again and it gives you it no matter how many numbers there are. Also I used double... the average of 1-10 is 5.5...

  • @Mewigi if u want to fix that use doubles

  • @TheTam999 Because it's not like I specifically said, "used doubles" in my comment.

  • oh, and dont forget the assignment operators from the 9th tutorial:

    instead of:

    total = total + grade; use:

    total += grade; ;D

  • change "average" to double and after the while-statement write

    average= total *1.0/counter; -to get a mathematically correct output without

    changing all variables to double, in case you only want to input integers.

  • For those you don't know if you want the true average just change int to double

  • Comment removed

  • I set it up to ask "How many number do you want to average?" then had that number set to a variable called numamount. Then I just put while (counter < numamount) and average = total/counter;

  • @Dawisc

    I did the same thing, except I called my variable "amount", and I wrote "average=total/amount"

    Oh, I also changed all the variables to double, because otherwise it wouldn't have given you the correct result (in most cases).

  • As soon as I learned switch statements I built a simple calculator.

  • make another varible the same as iput.nextint and use this instead of 10 in the counter and instead of total/10 put total/newvarible make the number of grades you want to enter different also make the variable average as double instead of int for correct ans

  • @mrHowToDoIt

    Exactly, bucky is a very good java programmer in my opinion. He really teaches me a lot:D