|
|
|
|
Title: Java Programming Tutorial - 21 - Simple Averaging Program
Added: May 10, 2009
Author: thenewboston
Duration: 6:11
Description:
How to build a simple program that averages 10 numbers in java.
Related Videos:
Videos related to 'Java Programming Tutorial - 21 - Simple Averaging Program'
Channel: Howto
Tags: install download jdk se ee java development kit new beginner tutorials eclipse variables if while loop object classes
install download jdk se ee java development kit new beginner tutorials eclipse variables if while loop object classes
Youtube Comments: 419
BlackDragonIVvids Says:
Apr 23, 2012 - Two this that could've made this code more efficient. Firstly, instead of dividing by 10, divide by the counter, it's more reliable.Additionally on like 13 you could've had "total += grade;"
farmerdwight Says:
Apr 23, 2012 - Shortcut: If you are using Eclipse and you press CTRL + Shift + O, then it will automatically figure out what imports you need such as "import java.util.Scanner" and insert that for you.
IlyasWidaad Says:
Apr 29, 2012 - what does the nextInt() method do? Why couldn't you just say grade = input? Your goal is to just take the input from the command line and store that value in the variable grade, correct? then wouldn't grade=input work? Please clarify, thanks. :-)
djleisheng Says:
Apr 29, 2012 - IlyasWidaad: if you do grade = input you are assigning the input object instance of Scanner to an integer. You have to use the method nextInt() to actually get what the person entered, otherwise you are just trying to get the entire object
IntenseGaming007 Says:
Apr 29, 2012 - If counter is less than 10 wouldn't it let you only input 9 numbers since it can only be less than ten. not equal to ten
khdalamoudi Says:
Apr 29, 2012 - Remember that the counter starts at 0, not 1, so you have 0, 1, 2 ... 9, and those are 10 :)
stephenpompeo Says:
May 1, 2012 - an int variable truncates decimals. a double would output 5.5
punkeltje Says:
May 2, 2012 - 7th and 8th line can be put together :Dint grade, average;and total = total + grade can betotal += gradekeeping it tidy xD
MrMetemer Says:
May 4, 2012 - my one asks how many grades you have! fuck yeah!
eldest808 Says:
May 4, 2012 - you rock dude thanks for these videos
drfrendor Says:
May 10, 2012 - You can also combine total and counter in that:int grade, average, total = 0, counter = 0;so you can get them all in one line. (=
Yøu Døn't Sày Says:
May 11, 2012 - 2:23 you have avast and it have been updated
TheSpadeNamedKade Says:
May 12, 2012 - Because of you, I went of making a even more advanced version of this!! Made me feel awesome :) thanks bucky :D
Freeminecraft000 Says:
May 12, 2012 - its made douch...and theres coder pack for mods
god4506 Says:
May 13, 2012 - what does this mean? Error occurred during initialization of VMCould not reserve enough space for object heap
IamTraversy Says:
May 15, 2012 - Using this tutorial and knowledge from the previous video, as well as a little trial and error, I made it ask how many numbers you wanted to average, and then it would ask for that amount of numbers.Then it would add up the numbers like it is supposed to, and divide it by the number for the average you entered. These tuts are great, I thank you for making them!!
AsasinationzStudio Says:
May 15, 2012 - Douche has an E, Douche. There was no need to insult him, the comment was over a month old anyway. Just shut up think before you talk...
Freeminecraft000 Says:
May 16, 2012 - @AsasinationzStudio maybe i wasnt insulting him. thers no need to insult me then!
IvanVinski2009 Says:
May 18, 2012 - Apparently he wants to make a mod for Minecraft.
metod137 Says:
May 19, 2012 - Kh-kh-khounter
punk6743 Says:
May 21, 2012 - add another variable and a print line asking how many numbers are being inputted, then use (var) = (scanner).nextInt();. use this variable in place of the 10 for the while parameter aswell as average = total/(var) in place of total/10. doing this will allow the user to choose the amount of numbers being inputted.
RatedProfessional Says:
May 21, 2012 - I literally just did that, and came to post for users to try lol. Make sure in the while loop you change < 10 to < (var) so the amount of trials the user inputted will be allowed to be inputted.
punk6743 Says:
May 22, 2012 - haha awesome!! great minds think alike! lol
superstarben37 Says:
May 25, 2012 - Bucky, you do realise that instead of doing 'total = total + grade', you can compact it and do 'total+=grade'?












NinjaEpix Says:
Apr 22, 2012 - its cuz he used the syntax's of int, which stands for integer, so it will always come out as a whole number