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" :)
@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
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);
@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 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.
@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"
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); }
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) ^^
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
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.
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.
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
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.
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.
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.
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.
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++; }
@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).
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 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
@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.
@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.
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();System.out.println("Begin entering numbers: \n");while(counter<n){grade=input.nextDouble();total=total+grade;counter++;}avg=total/10;System.out.println("Your Average is "+avg);}}
@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 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.
@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 .
@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.
@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.
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...
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;
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
who is learning Java to make android apps?
runslikeclockwork 2 days ago in playlist Bucky's Java Tutorial
Comment removed
MrYouMath 1 week ago
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 1 week ago
@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" :)
SmilesCast 4 days ago
Cya Latel
thebigbang100 2 weeks ago in playlist Java Programming Tutorials
@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
gamerslap 2 weeks ago
you can simply put (counter++ > 10) in the while loop.
imansetayesh2 2 weeks ago
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
DevilOnHog 3 weeks ago
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);
IamJacksColon4 3 weeks ago
lol!!!!at last i have understand tis code,why he ned counter and why it wil let u input for 10 times......
KimuraSetsuna 3 weeks ago
can anyone explain to me abot the counter part??
KimuraSetsuna 3 weeks ago
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
XxCrystalxNethxX 3 weeks ago
I actually got this one!!!
KristopherSw 3 weeks ago
I'm having problems, when I try to run it, it says that it can't find main class.
admirnaruto 4 weeks ago
@admirnaruto Perhaps you forgot the "public static void main (String[] args)" line?
Insomniac10102 3 weeks ago
@Insomniac10102 No I fixed the problem eclipse was giving me some problems.
admirnaruto 3 weeks ago
the average of 1 trough 10 is 10...
TheNotch3000 4 weeks ago
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?
MrKozeljko 4 weeks ago
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?
MrKozeljko 1 month ago
Who's learning this NOT to mod minecraft
williamsc 1 month ago in playlist Java Programming Tutorials 48
@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.
Decodeish1 2 weeks ago in playlist Java Programming Tutorials
@williamsc ME! :D
persiaTUT 2 weeks ago
@williamsc I'm learning this to make my OWN minecraft :D
RCPlaneFlyer16 1 week ago in playlist Java Programming Tutorials
@williamsc I'm just learning this to someday make my own 2D games. I've honestly never cared for making 3D games.
L3gendArch3r 1 week ago in playlist Java Programming Tutorials
@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.
EpicFailuresUnited 3 days ago
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 1 month ago 10
@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 1 week ago in playlist Learning Java-Beginners
@MrShubby12 Thank you mate :)
Justoneofthebrothers 1 week ago
there's no difference man :)
deeplookingman 6 days ago in playlist Java Programming Tutorials
you can just set grade to 0 and do "grade = grade + input.nextInt();". Then dont need four varibles, only three
agcummings11 1 month ago
thank you , i love bucky!!!!!
chaiyaram 1 month ago
3:14 KKK?!
gedist2 1 month ago in playlist Java Programming Tutorials
{O;O}
--( )--
/ \
OneAfter910 1 month ago
public static void main(Thank[]you);
:))
astigako12341 1 month ago
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
iEditEffects 1 month ago
damn, I always forget to click like on his videos. I think this is the first one I clicked...
TheLazus 2 months ago
I just can't thank you enough! God bless!
Fayzh 2 months ago
//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); }
}
MinerPenguin 2 months ago
//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?");
MinerPenguin 2 months ago
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,
MinerPenguin 2 months ago
Casting needed.
average = (float)total/10;
so you can get 5.5 instead of 5. (55/10=5.5)
eu2cy 2 months ago
@3:12 C-C-C-Counter Breaker!
KyleWannaKookie 2 months ago in playlist Java Programming Tutorials
While(Bucky == AWESOME){
System.out.println("You sir, are very awesome.");
}
thecoop022 2 months ago in playlist Java Programming Tutorials
Bucky...dude..you rock maan..Thank u...
vinumanumohan 2 months ago
I used "total += grade;" which also works
supermi123 2 months ago in playlist Java Programming Tutorials
And I thought my teachers were useless idiotic bastards .. but it seems like everyone around are complaining of there's too
q2828q 2 months ago
@q2828q Int and Double are numeric values, but a string consists of words "This is a string"
o0Richard 2 months ago
very nice tutorial, lol! Much better than my teachers :)
1SavageDragon1 2 months ago
i dont really understand what strings are can someone please explain them to me :( i would greatly appreciate it!
etizzei1 2 months ago
21 videos in a row, gotta piss.
EwPoxy 2 months ago in playlist Java Programming Tutorials
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 2 months ago
@Slugshot177 See tutorials 1 & 2
DHerls 2 months ago in playlist Java Programming Tutorials
great tutorials, this one has a slight flaw, the counter var is not nec
eggynack 3 months ago
Uhm.. the average of 1 through 10 = 5,5
So maybe wanna make the average a double ;)
Cheers!
ESVeritas 3 months ago in playlist Java Programming Tutorials
thanks ur realy helping us
Tiger360X 3 months ago in playlist Java Programming Tutorials
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.
pengro7 3 months ago in playlist Java Programming Tutorials
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?????
iamevildealwithit 3 months ago
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 3 months ago in playlist Java Programming Tutorials
@cplusplusgamer used total+=grade; and got 5...
JKTCGMV13 3 months ago in playlist More videos from thenewboston
@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.
TheXAlliance 3 months ago in playlist Java Programming Tutorials
System.out.println("WE LOVE YOU BUCKY");
xxnactise 3 months ago in playlist More videos from thenewboston
emmeran123 3 months ago
@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^^
dominik5467 3 months ago
@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
dominik5467 3 months ago
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
dominik5467 3 months ago
2:50 I'm not asking why don't you put {total = grade} I'm asking why you don't put {total += grade} ? =P
lee155912000 4 months ago in playlist Java Programming Tutorials
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.
StephanBerger 4 months ago
Tweaked so you can imput how many grades u want to average every time. =D
NightOwl79a 4 months ago
My schedule, wake up, goto school, come home, play minecraft, do homework, ten lessons of java. <3 bucky
SUPERGUITARIST888 4 months ago in playlist Java Programming Tutorials
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)
Shaldares 4 months ago 2
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);
belrosee 4 months ago
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.);
WhoLetTheGuyOut 4 months ago
Damn it why cant I learn this at school and only this?
Namingishard099 4 months ago in playlist Java Programming Tutorials
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!
xero907 4 months ago
who is learning this to mod minecraft :F
xero907 4 months ago 21
@xero907 me :D
MrDragonz102 4 months ago in playlist TheNewBoston - Java Programming
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.
michaeldcurry1 4 months ago in playlist TheNewBoston - Java Programming
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 4 months ago 31
@tal11333 I agree totally with you
graceymonterrey7 4 months ago
right now i was like= "get going youtube downloader"..".faster!!!!":)
69grabemo 4 months ago
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++; }
EpicnessPivotMaster 5 months ago
Beautiful! :D
EpicnessPivotMaster 5 months ago
0:47-0:50 sounds like he's singing.
xVerbati 5 months ago
average = total/counter would be better :P
SzaboB33 5 months ago
Notch learned from Bucky
I'm learning from Bucky
I'm gonna be the next NOTCH!
IWolfGod 5 months ago
@IWolfGod how did you know that notch learned from Bucky...if thats true
xVerbati 5 months ago
@IWolfGod notch didnt learn from bucky
DnL411 5 months ago in playlist thenewboston Java Tutorials
@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).
VaginosaurusRex 5 months ago
Finally, he uses the stuff he taught us to make an interesting "program". Good job!
Aaronster8 5 months ago
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 5 months ago 80
@Camczad258 ;
maxikahe 4 months ago
@Camczad258 you frogot the semicolon man ;)
ItzTheFury 4 months ago in playlist JAVA Tutorial (The New Boston)
@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 4 months ago
@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.
dumbnfilms 4 months ago in playlist Java Programming Tutorials
@Camczad258 Forgot the semicolon ;)
Mindstormscreator 4 months ago in playlist Java Programming Tutorials
@Camczad258 Wheres the semicolon?
DontDestroyTheHype 3 months ago 2
@Camczad258 He inspires you yet you forget the semi-colon at the end of your print statement? :( ;)
yourock129 3 months ago in playlist Java Programming Tutorials
@Camczad258 lol, you forgot to put the ' ; ' at the end
dunsha 3 months ago
@Camczad258 you forgot to end your statment with a semicolon
macoronicheez 3 months ago
@Camczad258 where is ;? :)
zagorec92 2 months ago
@Camczad258 LOL you forgot the ";" at the end :P
ismailzd 2 months ago in playlist TheNewBoston - Java Programming
@Camczad258 you forgot the semicolon.
dragonflies8677 1 month ago
@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
RynoFb 1 month ago in playlist Java Programming Tutorials
This has been flagged as spam show
@RynoFb if(Your school != Tech school){
System.out.println("Transfer schools");
}
:P
wolfaxe123 1 month ago in playlist Java Programming Tutorials
Well the last top comment a few vids ago seemed to say that he was the only minecrafter left, I AM STILL HERE!!!
Kriegergeist02 5 months ago
inputed...
*twitches*
AllThatStuffVids 5 months ago
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?
lilvdakota 5 months ago
Comment removed
superdatamaskin 5 months ago
Why can't I put in so many numbers as I want?? like 44444444444 and 888888888
superdatamaskin 5 months ago
@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 5 months ago
@WannabeTheAwesomest
Thanks dude :)
superdatamaskin 5 months ago
@superdatamaskin No problem :D
WannabeTheAwesomest 5 months ago
my question ïs; why always useing "int" when "double" gives you more precise answers?
superdatamaskin 6 months ago
@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.
lilvdakota 5 months ago
2:38 but what if I want to average it lato? Nice vids btw. Somehow addictive
Funk2929 6 months ago
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();System.out.println("Begin entering numbers: \n");while(counter<n){grade=input.nextDouble();total=total+grade;counter++;}avg=total/10;System.out.println("Your Average is "+avg);}}
Deathangelhj 6 months ago
@carrots087
thanks man
now i see my mistake ;)
ZebrAHeaD010 6 months ago
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 %
carrots087 6 months ago
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 6 months ago
@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
carrots087 6 months ago
@ZebrAHeaD010 Gimme your complete code...
Deathangelhj 6 months ago
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 6 months ago
i get an error with:
grade = input.nextInt();
RealMinecraftTV 6 months ago in playlist Java Programming Tutorials
@RealMinecraftTV must be "nextInt" no "nextint"
iiwudaffk 6 months ago
@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 6 months ago
@RealMinecraftTV
Reply me your code...I will try to resolve it...Ty..:)
Deathangelhj 6 months ago
@Deathangelhj I actually fixed it haha.. and I made a new workspace with mcp for minecraft anyway lol
RealMinecraftTV 6 months ago
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 6 months ago
@TheLimify it takes time for it to soak in
bondservant4Him 6 months ago
@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
chu240 6 months ago
i called my average double but i still dont get decimal averages. why is that
hizzleyo 6 months ago
Thumbs up if you're at this video already on the first night.
HarrowedBeThyName 7 months ago in playlist Java Programming Tutorials 79
@HarrowedBeThyName if i started at 9 pm yesterday, and it is 9 am right now does that count
xero907 4 months ago
@HarrowedBeThyName i got up to tutorial 42 :) im going through them again so i can remember them better
BrandonVIC96 4 months ago
@HarrowedBeThyName Dude this was my school day x)
Msz9Music 4 months ago
You can hav it as that but he was just showing us the average command and refreshing our memory
Bech6m 7 months ago
Shouldn't grade and average be double? And grade = input.nextDouble();? The average of 1-10 is 5.5.
MrSkateify 7 months ago 3
Comment removed
madabc1 7 months ago
@MrSkateify If you wanted to input decimal numbers and/or get a more accurate average, then yes.
otakughost 7 months ago
I'm making notes on what you say in these videos... In Java
kickman199811011 7 months ago
I love the way you pronounce the word "scanner". Everytime you say it I laugh.
NuMmErO15 7 months ago
And to think I used to think java was a kind of coffee.
AMVfanatic1081 7 months ago
@AMVfanatic1081 AND an island ;)
TheKyshu 6 months ago
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 7 months ago
@Proxymous Haha, i did the EXACT same thing! XD
Casey1859 6 months ago
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!
canadia7x 7 months ago
I love this guy
aMoodieNorway 7 months ago
Why did he set the int total = 0? Makes no sense
SargentSpecs 7 months ago in playlist Java Programming Tutorial
@SargentSpecs because total is 0 before any grades are added to it
MrJagaloon 7 months ago
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
basketballdude138 8 months ago
Rate this comment if you're less than 30 & wanna be the next notch xD
Alerhau 8 months ago
total supposed to divided by counter not 10 ! i mean average=total/counter.
great tutorials!thanks a lot!
tolquito 8 months ago
@tolquito technically it should be
average = total/counter--
otherwise you get one too many in the counter
lpminecraftvideos 8 months ago in playlist Java Tutorials
@lpminecraftvideos No cuz you do counter++ before the loop fails so counter is 10 afterwards
UlyssesKrunk 7 months ago
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 8 months ago
@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 8 months ago
@finroid : Thank you very much. I got it.
ptchau2003 8 months ago
@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.
fedgov011 8 months ago
no output for me
AutomatonGames 9 months ago
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.
nicsoadster 9 months ago
I DONT WANNA BE A TEACHER!!!
adonsaar 9 months ago
howcome whenever i do something and it spells it out it will do somethint like your average is5
BrandonCpatrick 9 months ago
@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.
Jovian2805 9 months ago
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
BrandonCpatrick 9 months ago
Amazing videos, these make JAVA simple!
RatmanXX 9 months ago
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 10 months ago
@Mewigi if u want to fix that use doubles
TheTam999 10 months ago
@TheTam999 Because it's not like I specifically said, "used doubles" in my comment.
Mewigi 9 months ago
oh, and dont forget the assignment operators from the 9th tutorial:
instead of:
total = total + grade; use:
total += grade; ;D
FreezySun 10 months ago
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.
FreezySun 10 months ago
For those you don't know if you want the true average just change int to double
Dusty2084 10 months ago
This has been flagged as spam show
If you are reading this then congratulations on being able to read.
wesiem1993 10 months ago
Comment removed
SuperGurkan1337 10 months ago
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;
Dawisch 10 months ago
@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).
Lacturu 10 months ago
As soon as I learned switch statements I built a simple calculator.
TheScars75 10 months ago
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
wellerccs 10 months ago
@mrHowToDoIt
Exactly, bucky is a very good java programmer in my opinion. He really teaches me a lot:D
supergunboy007 10 months ago