Satmaniac's Posts
Nairaland Forum › Satmaniac's Profile › Satmaniac's Posts
1 2 3 4 5 6 7 8 9 10 (of 12 pages)
Fulaman198:It's all right, I understand how busy you are I mean I.can see that your last comment was posted at 11:01pm and before that you posted 8:45pm. I know a lot of thread that lack of time killed, but, you still manage to take us this far, we know we are approaching page 5 now and still have a long way to go. I want you to know that we know how difficult a journey it is and we are with you to the end. May God bless and balance you. Thank you once again, Fulaman198. |
My second assignment our teacher Fulaman198 please check it up. import java.util.Scanner; class FleetWeight { public static void main(String[]args) { double weight; Scanner stdio = new Scanner(System.in); System.out.println("Please enter your vehicle weight in lbs." ;weight = stdio.nextDouble(); if(weight<=6000l) { System.out.println("Your vehicle is class 1 GVWR or VIUS light duty." ; if(weight>=6001 && weight<=10000) { System.out.println("Your vehicle is class2 GVWR or VIUS Light Duty." ; } }else if(weight>=10001 && weight<=14000 ) { System.out.println("Your Vehicle is class3 GVWR or VIUS Medium Duty." ;} else if(weight>=14001 && weight<=16000) { System.out.println("Your vehicle is class4 GVWR or VIUS Medium Duty" ; } else if(weight>=16001 && weight<=19500) { System.out.println("Your vehicle is class5 GVWR Medium Duty" ; } else if(weight>=19501 && weight<=26000) { System.out.println("your vehicle is class6 GVWR Medium Duty" ;} else if(weight>=26001 && weight<=33000) { System.out.println("Your Vehicle is class7 GVWR or VIUS Heavy Duty" ; } else if(weight>=33001) { System.out.println("Your vehicle is class8 GVWR && VIUS heavy duty" ;} } } I am sorry for inconviniencing you, I hope to receive some tips advice and corrections that could improve the code. Thanking you in advance. |
Fulaman198:I did some googling and discovered that the if-else and else-if control statement can be used for range of values as well as single values. For example, 1-99.99,100-199.99 and so on. On the other hand, according to the tutorial I have gotten from the result of the search I did, the SWITCH control statement can only be use for a definite values, hence can't be use for range of values. Now I am thinking of how to control the flow of execution using the switch in number range of such a large range. Imagine me using switch statement for a range as large as 6001-10000lbs, when it can't not be used for range of values. How possible is that? Anyway, you gave us option of using either Switch or if-if-else-else-if, with you preferring us using the switch. So, I will turn my assignment in using the if-if-else-else-if statement and hope you show us a way to use the switch statement on very large range of values. This is my dilemma. import java.util.Scanner; class SwitchScore { public static void main(String[]args) { int scores; Scanner stdio = new Scanner(System.in); System.out.println("Please, enter your score here" ;scores = stdio.nextInt(); switch(scores) { case 70: case 71: case 72: case 73: case 74: case 75: case 79: case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: case 100: System.out.println("You got an A" ;break; case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: System.out.println("You got a B" ;break; case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: System.out.println("You got C" ; break; default: System.out.println("We don't give lower than C grade" ;break; } } } |
asalimpo:Just like the vigilante in the seasonal film "Arrow" you always come to the rescue. Thanks Oga asalimpo. |
Fulaman198:This one strong o! See as I just dey sweat on top the assignment and still I am not making any headway. I have been having this illegal-start-of-an-expression error on my compiler. Hmm could it be that our teacher is trying to drive home some points about the difference in using the switch and the if-else-ifelse? Who don succeed make e come give me expo na. Or are we allowed to used google to helep solve this issue, our teacher Fulaman198? |
Fulaman198:Care to explain the line of code in blue, up above? |
Fulaman198:Goodnight, and have a wonderful night. This switch and and if-else-if-else statements is quite a powerful stuff. I will have to read day4 tutorial again to make sure I have a good understanding of the topic at hand. Thank you for taking time out of your busy schedule to see your students. |
Fulaman198:It is nice hearing from you again. *Heave a sigh of relief* Keeps ears to the ground. |
[quote author=Fulaman198 post=44688293][/quote]Salam, in an sami dama dinga tunawa da dalibanka na JAVA. A wuni lafiya. |
Fulaman198, I hope all is well at your end. It's just that
this silence is so uncomfortable. We hope to hearing from you sir. |
asalimpo:Hahahaha.......so you funny like dis? Ewa Java ati igbo Oshogbo. |
seunny4lif:Not with the way oga fulaman198 is putting us through. Have faith and remember that you could be able to spot the error in my code and it means you are learning well. |
seunny4lif:I know you will defeat OOP. |
seunny4lif:I know but you don epp na. |
satmaniac: |
Fulaman198: |
I can not quantify the happiness that swell in my heart right now. Finally, I am in luv, I never knew what it means to be in luv, until I met.... JAVA. Thanks for coming into my life JAVA. I will forever love you, oh my dear JAVA. |
seunny4lif:Now I know better, Thanks at seun4lif. |
Fulaman198:Yeah I have seen them and corrected all and the program compile fine. For the sake of forgetfulness, I will mark all the areas the errors are found in my code, so that I will be able to familiarise myself with such errors. Thank you for encouraging me. |
Fulaman198:It is true I was using my techno H5 with a partially broken screen, at that time. It is difficult to type out the characters on the screen, at times I need to turn the phone in order to change the screen orientation, so as to get to type some characters. My system is up now, I will compile after the correction, then I will report back here sir. Permission to fall out sir. |
Fulaman198:impport java.util.Scanner //wrong spelling of import. public class TestScores { public static void main(String[]args) { String name; double engScr,mathScr,phyScr,chemScr; double average ; // I really don't know why, I just assign a value of 0.0 to it. Probably, seen somewhere. Scanner stdio = new Scanner(System.in) ; System.out.println("Enter your name pls" ;name = stdio.nextLine(); System.out.println("Pls, enter your English test score" ; // The out println statement should be on one single line.engScr = stdio.nextDouble(); System.out.println("Pls, enter your Math test Score" ;mathScr = stdio.nextDouble(); System.out.println("Pls, enter your Physics score" ; //Should all be in one single line.phyScore = stdio.nextDouble(); // phyScore did not match the declared phyScr System.out.println("Pls, Enter your Chemistry score" ; // Have to be on single line.chemScore = stdio.nextDouble(); //chemScore did not match the declared chemScr average = (engScr + mathScr + phyScr chemScr)/4 // Forget to end it with a semicolon( ![]() System.out.println("Welcome" + name + "Your average score is" + average); // Should be on single line and no semicolon( } } Looking forward to corrections from all. |
Fulaman198:I was just excited at the way you are literally putting java concept into our skulls that I couldn't see the variable values given by you. Anyway, It's been taken care of. |
public class MultiAdd { int num1 = 80; int num2 = 1010; public static void main(String[]args) { addigit = num1 + num2; multdigit = num1 * num2; System.out.println(addigit); System.out.println(multdigit); } } Modified |
FARM LAND |
How did you make this so simple? God thank you for showing me this thread. Thank you fulaman! |
asalimpo:Oh... got it man. Thanks! |
Grateful for your contributions, it worked after implementing what you recommended. However, I will want to know why it didn't work even after using "import java.util.math". I mean why would "import java.lang.math" work and "java util.math" refused to work? @asalimpo I will make sure I do that as it will save me needless headache. |
dhtml18:Hehehehe.......Suicide indeed. The thing frustrate sotay I come dey reason am say na one old witch dey responsible oh. This my African mindset sef. |
@asalimpo, dhtml18, and larisoft, I am very grateful of your kindness and generosity and I am also sorry for posting it here instead of creating a thread. Make una no vex, una know say for programming una be elders and me be una last born. Una kukuma know say last born tend to misbehave sometime, so, make una no binu oh. Judging by your responses, I have no single doubt that I am in good and capable hands. Thanks, once again, elder broses. Now, let me go try it out, I will report what transpire ASAP. |
larisoft:Hello larisoft, your post is one of the few posts I enjoy reading on Nairaland, especially, here in the programming section. Although, this piece may not be of use to me, as I am just starting out as a beginner in programming, That will not deny me the privilege of accessing your assistance and that of other programming gurus here. In my quest to learn programming, I picked Java and I have been quietly studying some books as well as watching some videos I got from the internet and off course, I put what I learnt into practice. As you know, a beginner like me will encounter some hitches or challenges in the form of errors in my written codes, I am currently having issues with my java class methods. The problem is that I have been trying to no avail, to make my java class method work. For example, the math class like Math.random(); or Math,sqrt(); refuses to work and have been displaying this error: "Can not find symbol System,out.println(Math.random(number)); Symbol: random(int) Location: class Math " I really need to know why it is displaying this error. Below is the entire code: public class Math { public static void main(String[]args) { int x = 100; System.out.println(Math.random(x)); //System.out.println(Math.sqrt(x)); } } This error is driving me nuts, save my sanity........ Ccc larisoft, dhtml18, seunthomas, Danielthegeek, asalimpo and others. |
;
