Satmaniac's Posts
Nairaland Forum › Satmaniac's Profile › Satmaniac's Posts
1 2 3 4 5 6 7 8 9 10 (of 12 pages)
Collinz2:You don download am? |
Fulaman198:I have downloaded the netbeans IDE. Hi all! if you don download your own, raise up your hand. |
pachman:We have a good teacher in fulaman, basically, I will shout it from the roof top that we are in good hands.That is why, I always pray for his success in whatever he is doing, including teaching us. You need to see my face whenever I am manipulating codes, pure joy and happiness unquantifiable. I have never taking anything intoxicating, but whenever I am doing our assignment people kind of think that I am intoxicated, because I am always happy, especially when I get the program to work the way I expect it to. |
pachman:When I tried using while last time it didn't work, but after some modification this works exactly as I want it to. import java.util.Scanner; public class Array{ public static void main(String[]args){ int i=0; int[]Scores; double average=0; int total=0; System.out.println("This program collect Scores of students in ten subjects and also display their average." ;Scores = new int[10]; Scanner stdio = new Scanner(System.in); for(i=0;i<Scores.length;i++){ System.out.println("Please enter Test Score" + i + ":" ;Scores[i] = stdio.nextInt(); while(Scores[i]<=-1 || Scores[i]>100){ System.out.println("Score is less than zero, or greater than 100, please, enter a valid score!" ;Scores[i] = stdio.nextInt(); } Scores[i]++; total+=Scores[i]; } average=total/Scores.length; System.out.println("Your average is:" + " " + average); } } |
Fulaman198:I have no idea what you are talking about, sounds like greek to me. Although from the picture, I can see that the guy did a great job, I mean the information he represented in image in the applets. Bro, as complete newbie wey we bee, correction go good for us, na dat one go take make our hand strong kakaraka for coding. Thanks for gingering us, it will soon lead to some goods and we appreciate your support. |
Fulaman198:I did it! I can feel it! Yes! Yes! OMG! I will modify my comment cotaining the codes. Kai kai! Fulaman198 is a good teacher. |
pachman:I tried modifying my code to reflect yours, but, the loop no want stop. It seem what I suspected initially was correct. Sharp guy! You don enter Classes ans Objects? Nawa 4 u o. |
pachman:Looking at your while loop block, I have no doubt it will work. Initially, the lack of the count increment, almost got me confused, as that is what will render the condition in the while braces false at a point in the program, thereby terminating the iteration. I later realised that if the value you enter is not less than zero nor greater than 100, the condition in the while loop braces will rendered the input as false. Thank you very much pachman, you really save someone sanity. I have been on this for days now. Thank ya @ pachman(try change dat name to packwoman). Are you also a beginer like me? |
Fulaman198:I did something nearly similar to Korlahwole,s codes, the first day you posted the assignment, but, I was not sure if I it was correct, for, I reasoned what if the user of the programme entered numbers that are less than zero, say three times, when the programme can not iterate more than than the array size, in this case Scores.length? That means the scores entered will not be up to ten, if you minus the wrong scores entered. As a result of this problem I wasted time looking for a way to do it better. Is there a way someone can write the programme, to accommodate such or more wrong entries from the user? Because, I tried and was having a RuntimeException- array-out-of-index error. The initial code below: I had to modify the codes as it, it didn't work as expected, But this does. Sir Fulaman198 pachman make una help me touch light am import java.util.Scanner; public class Array{ public static void main(String[]args){ int i=0; int[]Scores; double average=0; int total=0; System.out.println("This program collect Scores of students in ten subjects and also display their average." ;Scores = new int[10]; Scanner stdio = new Scanner(System.in); for(i=0;i<Scores.length;i++){ System.out.println("Please enter Test Score" + i + ":" ;Scores[i] = stdio.nextInt(); if(Scores[i]<=-1 & Scores[i]>100){ System.out.println("Score is less than zero, or greater than 100, please, enter a valid score!" ;Scores[i]--; } Scores[i]++; total+=Scores[i]; } average=total/Scores.length; System.out.println("Your average is:" + " " + average); } } |
larisoft:You got mail. |
larisoft:E be like say you know no say your name dey on your blog o. Abi you think say people no dey read your sense making article on your potentials filled blog? I go soon flash you Na joke o.However I got a coding problem and it seem this is the perfect opportunity to lay bare the problem to you, but I don't know what is wrong with nairaland PM, for I have tried PMing you and for some unknown reasons I couldn't get to type into the text field on the PM page. |
ANTONINEUTRON see wetin u don cause? Now him wan push bone come give us. Fear don catch me already. Fulaman198: |
ANTONINEUTRON:Why you come dey open teeth? Abi you wan show our tisha(Fulaman198) say you get strong teeth scatter bones and hard 'pomo'? Oga tisha, no look this guy big and strong teeth come give us hard pomo(assignment) o, as I no follow get that kind teeth o. if na lie check am see? na emmpty oo! |
Fulaman198:Will appreciate it oo. As I am typing on my tecno h5 phone, my eyes glued to lesson 4 page I opened on the screen of my 15th century Nigerian laptop. Let me know if I am ready to join you guys in lesson 6, pls. |
You made it looked so easy, but I am sure the assignment is definitely going to be as tough as poorly cook 'pomo', but I like that. And I will like to hear what you think about the corrected version of assignment I submitted. Do I need to go back to lesson 4? |
Fulaman198:No wahala bro, I and I guess others too know how busy you are. |
DjAndroid: |
Abagworo: |
Sugarhugs: ? |
Fulaman198:Aha got it....project tinz. Remember rest is also a weapon against sickness. |
ANTONINEUTRON:Good morning everybody Oya make una wake up, I see teacher dey come class. Shebi na 2day in dey teach us arrange....sorry...erm...wetin be the name self....hit head and stamp feet on the ground...Ok now I don get am. Array. So dis guy too don tey for the game. Thumb up bro. Come o! This one wey our teacher never show face so, hope say that fine lady never carry her feet match our teacher face o Bia, Sugarhugs, come explain yasef before we pronounce you guilty.You know say, the instruction was to put feet on his face, no go match our oga face o ![]() |
freeborn76:Dr freeborn76 don find the problem o, make una kuku go find solution to una problem ![]() Ezeife talk something and una just believe say na wetin happen be that? Una need cure for this una hatred. |
And the assignment 2 Day 5, I hope I dey right: import java.util.Scanner; import java.lang.Math; public class Guess{ public static void main(String[]args){ int count = 0; int numberGuessed = 0; int randomNumber = (int)((Math.random() * 100) + 1); Scanner stdio = new Scanner(System.in); while(numberGuessed!=randomNumber){ System.out.println("Please guess a number between 1 and 100" ;numberGuessed = stdio.nextInt(); count++; } System.out.println("You win! After" + " " + count++ + " " + "times" ); } } |
Alternatively, using if-else-if-else flow control statement, assignment 1 Day 5 will look like this: import java.util.Scanner; public class HelloWorld{ public static void main(String[]args){ int selectedConversionUnit = 0; int tries = 0; double centemeter; double cmresult; double metres; double ftresult; double celsius; double clresult; double naira; double nrresult; Scanner stdio = new Scanner(System.in); while(selectedConversionUnit>=0){ System.out.println("please enter a value here:" ;selectedConversionUnit = stdio.nextInt(); tries++; if(selectedConversionUnit==1){ System.out.println("Enter your value in centemeter here:" ;centemeter = stdio.nextDouble(); cmresult = centemeter/2.54; System.out.println(centemeter+ " " + " equivalent in inch is " + " " + cmresult + "inches " ;} else if(selectedConversionUnit==2){ System.out.println("Enter your value in metres here:" ;metres = stdio.nextDouble(); ftresult =metres/3.28; System.out.println( metres + "equivalent in feet is: " + " " + ftresult + "feets" ); } else if(selectedConversionUnit==3){ System.out.println("Enter your value in Celsius here:" ;celsius = stdio.nextDouble(); clresult = 32+(9/5)*celsius; System.out.println(celsius + " " + " equivalent in fahreinheits is " + " " + clresult +" " + "fahreinheits." ;} else if(selectedConversionUnit==4){ System.out.println("Enter your value in Naira:" ;naira = stdio.nextDouble(); nrresult = naira/227.96; System.out.println(naira + " " + "equivalent in euro is " + " " + nrresult + " " + "euros" ;}else if(selectedConversionUnit==5){ System.exit(0); } } } } Sorry o! I don develop some kind of bias towards if-else-if-else control statement, so, include am |
Fulaman198:I am sorry @crotonite, for I am the one holding us back. I finished the corrections based on the advice of oga Fulaman198, since yesterday. I will hasten to post them one after the other, in a separate post, so we could move ahead. Oga, Fulaman198, here is assignment 1 Day 5: import java.util.Scanner; public class Convert{ public static void main(String[]args){ int count=0; int selectedConversionUnit = 0 ; double centimeter; double celsius; double naira; double meter; Scanner stdio = new Scanner(System.in); while(selectedConversionUnit>=0) { System.out.println("Please enter a digit here:" ; selectedConversionUnit = stdio.nextInt(); count++; switch(selectedConversionUnit){ case 1: System.out.println("Please enter a value in centimeter here:" ;centimeter = stdio.nextDouble(); System.out.println(centimeter + " " + "Equivalent in inches is:" + " " + centimeter/2.54 + "inches" ;break; case 2: System.out.println("Please enter a value in meter here:" ;meter = stdio.nextDouble(); System.out.println(meter + " " + "Equivalent in feets is:" + " " + meter/3.28 + "feets" ;break; case 3: System.out.println("Please enter a value in Celsius here:" ;celsius = stdio.nextDouble(); System.out.println(celsius + "C" + " " + "Equivalent in fahreinheits is:" + " " + 32+(9/5)*celsius + "fahreinheits" ; break; case 4: System.out.println("Please enter a value in Naira here:" ;naira = stdio.nextDouble(); System.out.println( naira + "Naira" + " " + "Equivalent in Euros is:" + " " + naira/227.96 + "euros" ; break; case 5: System.exit(0); break; default: } } } } |
Fulaman198, sir, how can I implement a code that will tell me the number of times the user guessed before getting it right? I tried using count++ and I know it is wrong, otherwise, my code seems to run well for me here. I tested it by reducing the range from 1-5 instead of the one given and it work well. I will appreciate if you point out anything that is missing or not right in the codes. Thanks. |
[center]Assignment 2 Day 5[/center] import java.util.Scanner; import java.lang.Math; public class Guess{ public static void main(String[]args){ int count = 0; int enter; int rndm = (int)((Math.random() * 100) + 1); Scanner stdio = new Scanner(System.in); while(count<=100){ System.out.println("Please guess a number between 1 and 100" ;enter = stdio.nextInt(); count++; if(enter==rndm){ System.out.println("You win! You got it after" + " " + count++ + " " + "attempts" ;}else{ System.out.println("Wrong guess" ;} } } } |
Here is the Assignment 1 using Switch control statement: import java.util.Scanner; public class Convert{ public static void main(String[]args){ int count=0; int enter ; double centimeter; double celsius; double naira; double meter; Scanner stdio = new Scanner(System.in); while(count<=4) { System.out.println("Please enter a digit here:" ; enter = stdio.nextInt(); count++; switch(enter){ case 1: System.out.println("Please enter a value in centimeter here:" ;centimeter = stdio.nextDouble(); System.out.println(centimeter + " " + "Equivalent in inches is:" + " " + centimeter/2.54 + "inches" ;break; case 2: System.out.println("Please enter a value in meter here:" ;meter = stdio.nextDouble(); System.out.println(meter + " " + "Equivalent in feets is:" + " " + meter/3.28 + "feets" ;break; case 3: System.out.println("Please enter a value in Celsius here:" ;celsius = stdio.nextDouble(); System.out.println(celsius + "C" + " " + "Equivalent in fahreinheits is:" + " " + 32+(9/5)*celsius + "fahreinheits" ; break; case 4: System.out.println("Please enter a value in Naira here:" ;naira = stdio.nextDouble(); System.out.println( naira + "Naira" + " " + "Equivalent in Euros is:" + " " + naira/227.96 + "euros" ; break; case 5: System.exit(0); break; default: } } } } |
Fulaman198:I corrected it and it is now working perfectly, I am going to post it and I hope this time, it is going to earn me pass mark ![]() So, it is now official that I have been demoted to class....erm...Day 4. I been dey think say nobody smart pass me, but now I know a lot of people are. crotonite, well done o! I go soon sabi pass you ![]() Rush back to SS4....erm...class4....sorry, I mean assignment4, before senior crotonite comot im koboko ![]() Abeg Sugarhugs will you do us a favour and cover your feet in those pair of black ninja socks? Make our teacher no go use feet do topic for Day7 ![]() |
Fulaman198:Thanks a lot for the advice. About not incrementing tries, I did increment tries in the first assignment. Perhaps the spacing of the codes is too compact that you missed it, it is on the third statement inside the while block. Also, I tried using switch control statement and I have errrors on my compiler, whenever I compiled it, hence, I decided to use if-else-if control statement and it compiled and run without error. However, I will still try using the switch control statement and when it compile well, I will post it here too. On the second assignment, I compiled it too and it did not show me any error, but since I run the programme, I was not able to guess the correct answer, that is the value entered has not match the randomly generated number till now. So,it seem the problem I may be having is not with the syntax, maybe, logical problem. I will not pretend and act as if I understand what you said about not wanting to initialise my count to 0. If you don't mind could you throw more light on it? I mean why would I initialise tries to 0 in assignment 1 and can not do the same in assignment 2? About posting my assignment on a separate comment, this is a mistake I will never repeat again. Thanks. [size=10]MODIFIED[/size I checked the code I posted here on nairaland and I discovered that there are a lot of mistake mistake in it, especially, the concatenation. So, the compiler will definitely call out the errors. So, here is the code as it is on my notepad++ text editor: import java.util.Scanner; public class HelloWorld{ public static void main(String[]args){ int enter; int tries = 0; double centemeter; double cmresult; double metres; double ftresult; double celsius; double clresult; double naira; double nrresult; Scanner stdio = new Scanner(System.in); while(tries<=5){ System.out.println("please enter a value here:" ;enter = stdio.nextInt(); tries++; if(enter==1){ System.out.println("Enter your value in centemeter here:" ;centemeter = stdio.nextDouble(); cmresult = centemeter/2.54; System.out.println(centemeter+ " " + " equivalent in inch is " + " " + cmresult + "inches " ;} else if(enter==2){ System.out.println("Enter your value in metres here:" ;metres = stdio.nextDouble(); ftresult =metres/3.28; System.out.println( metres + "equivalent in feet is: " + " " + ftresult + "feets" ); } else if(enter==3){ System.out.println("Enter your value in Celsius here:" ;celsius = stdio.nextDouble(); clresult = 32+(9/5)*celsius; System.out.println(celsius + " " + " equivalent in fahreinheits is " + " " + clresult +" " + "fahreinheits." ;} else if(enter==4){ System.out.println("Enter your value in Naira:" ;naira = stdio.nextDouble(); nrresult = naira/227.96; System.out.println(naira + " " + "equivalent in euro is " + " " + nrresult + " " + "euros" ;}else if(enter>=5){ } } } } |
Fulaman198:First assignment Day 5 import java.util.Scanner; public class Converter{ public static void main(String[]args){ int enter; int tries = 0; double centemeter; double cmresult; double metres; double ftresult; double celsius; double clresult; double naira; double nrresult; Scanner stdio = new Scanner(System.in); while(tries<=5){ System.out.println("please enter a value here:" ;enter = stdio.nextInt(); tries++; if(enter==1){ System.out.println("Enter your value in centemeter here:" ;centemeter = stdio.nextDouble(); cmresult = centemeter/2.54; System.out.println(centemeter+ " " " equivalent in inch is " + " " + cmresult + "inches " ;} else if(enter==2){ System.out.println("Enter your value in metres here:" ;metres = stdio.nextDouble(); ftresult =metres/3.28; System.out.println( metres + "equivalent in feet is: " + " " + ftresult + "feets" ); } else if(enter==3){ System.out.println("Enter your value in Celsius her:" ;celsius = stdio.nextDouble(); clresult = 32+(9/5)*celsius; System.out.println(celsius + " equivalent in fahreinheits is "clresult +" " + "fahreinheits." ;} else if(enter==4){ System.out.println("Enter your value in Naira:" ;naira = stdio.nextDouble(); nrresult = naira/227.96; System.out.println(naira + "equivalent in euro is "nrresult + " " + "euros" ;}else if(enter>=5){ } } } } Solution to Assignment 2 Day 5 import java.util.Scanner; import java.lang.Math; public class Guess{ public static void main(String[]args){ int count = 0; double rndm = (int)((Math.random() * 100) + 1); Scanner stdio = new Scanner(System.in); while(count<=100){ System.out.println("Please guess a numbber between 1 and 100" ;count = stdio.nextInt(); count++; if(count==rndm){ System.out.println("You wint it took you" + count++ + "times to get it right" ;}else{ } } } } Advice, tips, and everything that can improve my codes will be appreciated, thanks Fulaman198. |
Fulaman198:We re grateful sir. We are gradually progressing in this journey |
;
see? na emmpty oo!
Oya make una wake up, I see teacher dey come class. Shebi na 2day in dey teach us arrange....sorry...erm...wetin be the name self....hit head and stamp feet on the ground...Ok now I don get am. Array.