Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,707 members, 7,820,483 topics. Date: Tuesday, 07 May 2024 at 03:37 PM

Learning To Program With Java by the Fulaman - Programming (5) - Nairaland

Nairaland Forum / Science/Technology / Programming / Learning To Program With Java by the Fulaman (41630 Views)

How To Program Arduino Uno / How To Program With Your Android Phone Using Aide IDE Environment / Which Training Center Can Someone Learn How To Program Quickly (2) (3) (4)

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (16) (Reply) (Go Down)

Re: Learning To Program With Java by the Fulaman by asalimpo(m): 7:22pm On Apr 15, 2016
Dekatron:
@Asalimpo and Fulaman198, how do I print a value together with another. I mean :- look at python :-


print('1\b2\b3')
would print :-

123 TOGETHER


Like your teacher had said, string concatenation does it. But at a higher level,
c-style print statements can also be used for printing certain data types . It's more compact and saves on effort.

e.g
to print the digits:
int x=1,y=2,z=3;
you do this:


System.out.printf("These are %d%d%d ",x,y,z);


the output:

These are digits 123


the
 %d 
represents a number (integer).

the alternative would be this:
System.out.println("These are digits "+x+""+y+""+z);
Re: Learning To Program With Java by the Fulaman by edaloba(m): 10:25pm On Apr 15, 2016
would really love to follow buh the network here is always bad, dunno how I can make it sir
Re: Learning To Program With Java by the Fulaman by Damoxy(m): 6:28pm On Apr 16, 2016
Fulaman198:

http://www.tutorialspoint.com/android/index.htm
tanks bro,just dt I would prefer videos
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 6:43pm On Apr 16, 2016
Damoxy:

tanks bro,just dt I would prefer videos

https://www.coursera.org/course/androidpart1
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 6:46pm On Apr 16, 2016
crotonite:

the attached image is not clear on my mobile device. what i want is that you rename the image to something like: 'image_name.jpg.zip' b4 uploading so that i can dowload it instead. tnx

Hey bro, if you hold down on your screen you should be able to download the image.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 8:02am On Apr 17, 2016
This assignment must be tough for you guys. No one has turned it in yet.
Re: Learning To Program With Java by the Fulaman by satmaniac(m): 9:03am On Apr 17, 2016
Fulaman198:
This assignment must be tough for you guys. No one has turned it in yet.


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"wink;

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"wink;
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"wink;
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"wink;
break;

default: System.out.println("We don't give lower than C grade"wink;
break;
}



}


}
Re: Learning To Program With Java by the Fulaman by Nobody: 9:32am On Apr 17, 2016
Sorry 4 disturbing @fulaman198. the attached image is actually the picture of my phone appended to a yagi gsm antenna that is because i stay in an area that is out network coverage lipsrsealed. my smartphone does not work with an external antenna. that is why i browse with a feature phone.

btw i tried renaming the image file to 'my_phone.jpg.zip', and nairaland web server renamed it back to 'my_phone.jpg.zip.jpeg' how does it know that the file was actually an jpg file?

Re: Learning To Program With Java by the Fulaman by ANTONINEUTRON(m): 12:11pm On Apr 17, 2016
Geez it's hard!

I don't understand using if-else for multiple figures like 1-5000 because in the kg assignment, user's cud input 9620kg waiting for the system to convert it to ibs.
And u dnt expect smeone to write d if-else statement till infinity.


Using the switch statement for question 1 is possible because it contain 30-100 figure
Re: Learning To Program With Java by the Fulaman by satmaniac(m): 1:42pm On Apr 17, 2016
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."wink;
weight = stdio.nextDouble();

if(weight<=6000l)
{
System.out.println("Your vehicle is class 1 GVWR or VIUS light duty."wink;
if(weight>=6001 && weight<=10000)
{
System.out.println("Your vehicle is class2 GVWR or VIUS Light Duty."wink;
}

}else if(weight>=10001 && weight<=14000 )
{
System.out.println("Your Vehicle is class3 GVWR or VIUS Medium Duty."wink;
}

else if(weight>=14001 && weight<=16000)
{
System.out.println("Your vehicle is class4 GVWR or VIUS Medium Duty"wink;

}

else if(weight>=16001 && weight<=19500)
{
System.out.println("Your vehicle is class5 GVWR Medium Duty"wink;
}

else if(weight>=19501 && weight<=26000)
{

System.out.println("your vehicle is class6 GVWR Medium Duty"wink;
}


else if(weight>=26001 && weight<=33000)
{

System.out.println("Your Vehicle is class7 GVWR or VIUS Heavy Duty"wink;
}

else if(weight>=33001)
{
System.out.println("Your vehicle is class8 GVWR && VIUS heavy duty"wink;
}



}
}


I am sorry for inconviniencing you, I hope to receive some tips advice and corrections that could improve the code. Thanking you in advance.
Re: Learning To Program With Java by the Fulaman by Nobody: 5:25pm On Apr 17, 2016
i finally dowloaded the table. here is my solution for the assignment.

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 8:45pm On Apr 19, 2016
This thread will be updated again soon. I promise.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 11:01pm On Apr 19, 2016
I will update this thread with a tutorial on iteration hopefully Friday or Saturday and have your assignments that you guys have submitted hopefully by Thursday. Iteration will cover for loops, do-while loops, and while loops. If you want, you can read ahead now before I do the tutorial and give you guys more practise assignments. Best of luck!
Re: Learning To Program With Java by the Fulaman by satmaniac(m): 2:06am On Apr 20, 2016
Fulaman198:
I will update this thread with a tutorial on iteration hopefully Friday or Saturday and have your assignments that you guys have submitted hopefully by Thursday. Iteration will cover for loops, do-while loops, and while loops. If you want, you can read ahead now before I do the tutorial and give you guys more practise assignments. Best of luck!

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.
Re: Learning To Program With Java by the Fulaman by Collinz2(m): 11:08am On Apr 20, 2016
Is it just me or the java language. Anytime i read online tut at first i get the msg but later i wil be totally confuse.
Re: Learning To Program With Java by the Fulaman by Kendzyma(m): 10:46pm On Apr 20, 2016
hi Mr fulaman,great work up der....still a learner though,...but having a prob....
I wana no if I will av to create a new package entirely when caling d method of anoda class.....asing I created a class and a method,but wana use the method I created in anoda class..is it dat I will create a new class under same package to b able to call d class method ?...or I will created an entirely new package?....
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 3:39am On Apr 21, 2016
Kendzyma:
hi Mr fulaman,great work up der....still a learner though,...but having a prob....
I wana no if I will av to create a new package entirely when caling d method of anoda class.....asing I created a class and a method,but wana use the method I created in anoda class..is it dat I will create a new class under same package to b able to call d class method ?...or I will created an entirely new package?....

If you want to use a class and its method in another class, all you have to do is import the class via the 'import' keyword. If your class is public and the method itself is public you should be fine.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 9:49pm On Apr 21, 2016
ANTONINEUTRON:
Geez it's hard!

I don't understand using if-else for multiple figures like 1-5000 because in the kg assignment, user's cud input 9620kg waiting for the system to convert it to ibs.
And u dnt expect smeone to write d if-else statement till infinity.


Using the switch statement for question 1 is possible because it contain 30-100 figure

Greetings Antonineutron young computer scientist. If you look at the original example in which I had the if statement joined with the &&, you can see how to do ranges. so look at the grading assignment where i said


if (grade >= 70 && grade <= 100) {
System.out.println("Grade is an A." ) ;
}


That is how one checks if a value is between two ranges. You call the variable twice in the same expression that you are testing for.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 9:52pm On Apr 21, 2016
satmaniac:
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."wink;
weight = stdio.nextDouble();

if(weight<=6000l)
{
System.out.println("Your vehicle is class 1 GVWR or VIUS light duty."wink;
if(weight>=6001 && weight<=10000)
{
System.out.println("Your vehicle is class2 GVWR or VIUS Light Duty."wink;
}

}else if(weight>=10001 && weight<=14000 )
{
System.out.println("Your Vehicle is class3 GVWR or VIUS Medium Duty."wink;
}

else if(weight>=14001 && weight<=16000)
{
System.out.println("Your vehicle is class4 GVWR or VIUS Medium Duty"wink;

}

else if(weight>=16001 && weight<=19500)
{
System.out.println("Your vehicle is class5 GVWR Medium Duty"wink;
}

else if(weight>=19501 && weight<=26000)
{

System.out.println("your vehicle is class6 GVWR Medium Duty"wink;
}


else if(weight>=26001 && weight<=33000)
{

System.out.println("Your Vehicle is class7 GVWR or VIUS Heavy Duty"wink;
}

else if(weight>=33001)
{
System.out.println("Your vehicle is class8 GVWR && VIUS heavy duty"wink;
}



}
}


I am sorry for inconviniencing you, I hope to receive some tips advice and corrections that could improve the code. Thanking you in advance.

The code looks great and you are not inconveniencing me one bit. One bit of advice for you, you want to use proper spacing to make your code look more legible to others. Other than that your logic and your code is completely correct.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 9:56pm On Apr 21, 2016
crotonite:
i finally dowloaded the table. here is my solution for the assignment.

It's nicely done. You did it in a fashion that I prefer, combining if-else conditional statements with the switch statement. I'm impressed, nicely done!

1 Like

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 9:59pm On Apr 21, 2016
Those of you whom have already turned in your assignments, nicely done. I will put up another assignment and tutorial tomorrow. Keep up the excellent work.
Re: Learning To Program With Java by the Fulaman by macaranta(m): 11:32am On Apr 22, 2016
Fulaman198:
Those of you whom have already turned in your assignments, nicely done. I will put up another assignment and tutorial tomorrow. Keep up the excellent work.

Hi Fulaman,will you like to partner with our website to create(and possibly sell) programming courses using [url]macaranta.com[/url].??
Re: Learning To Program With Java by the Fulaman by ANTONINEUTRON(m): 3:03pm On Apr 22, 2016
Fulaman198:


Greetings Antonineutron young computer scientist. If you look at the original example in which I had the if statement joined with the &&, you can see how to do ranges. so look at the grading assignment where i said


if (grade >= 70 && grade <= 100) {
System.out.println("Grade is an A." ) ;
}


That is how one checks if a value is between two ranges. You call the variable twice in the same expression that you are testing for.
oh

it din't even crossed my mind.


...Continue Fulaman am following...
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 11:59pm On Apr 22, 2016
Day 5:

It has been a while since I last posted. I will be posting Day 5 material in 2 to 3 waves, meaning I will post only wave 1 on 22 April, 2016. Wave 2 will be posted sometime in the evening/night tomorrow (like it is night right now).

Often, we want to be able to print data or iterate (loop) through a large block of code without having to write it down physically. Let us say for instance if I wanted to print "Hello, welcome to the World of Java" 100 times to the screen. What would be one of the most efficient ways to do that from a coding perspective? Well, today, you, the reader will be introduced to a phenomenon known as iteration (or looping).

In Java, and other C-based languages, there are three different types of loops you should familiarise yourself with. The "For" loop, the "Do-while" loop, and the "while" loop. Each loop is capable of accomplishing very similar things. In the end, it boils down the preference of what you want to do with the loop.

Let us go back to my previous example of printing data, let's say I asked you to printout "Hello, welcome to the World of Java" 15 times. Would you write a System.out.println() statement 15 times? Absolutely not! It would look utterly ridiculous.

The For Loop:

Syntax:

for (initialization; termination;
increment) {
statement(s)
}

I will now illustrate how one would do that via some code. See the screenshot below.

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 12:06am On Apr 23, 2016
via the Output, we get the screenshot below. It's amazing what you can do with looping. This kind of loop is called the for loop. the first part before the semi-colon is known as the initialization conditional statement for the for loop, the second part before the second semi-colon is known as the termination point for the for loop. The third part before the 3rd semi-colon is known as the increment (or decrement) statement.

If we look at the previous screenshot I posted with the source code, in the for loop, I'm telling the computer to print to the console Hello World 15 times. The initialization condition starts at 0 (thus the count starts at 0), the termination point of the loop ends at 14 (because we tell the loop to stop at less than 15. However, 0 - 14 is 15 times (whereas 1 - 14 is 14 times). the i++ statement which is the increment statement means to add 1 to i after the iteration is complete.

i++ is the equivalent to i = i + 1. You may from time to time see ++i. This just means to add 1 before you increment. We will go over more of this logic later on.

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 12:18am On Apr 23, 2016
If we wanted to do a count down in Java from 20 to 1, how would we do it? Very simply put, remember what the 3 conditional statements stand for? The initial condition would be to set a variable (preferably an int) in the for loop conditional to 20, since we want to count down to 1, our termination conditional (the second part of the for loop statement) should be the int is greater than or equal to 1. The final condition would be to decrement the int 1 time per iteration phase. See example below:

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 12:19am On Apr 23, 2016
The resulting output is below

1 Like

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 12:21am On Apr 23, 2016
Looping is very important, we will find ourselves delving more into loops later on even after this tutorial when we get into arrays. For your assignment since this Day 5 tutorial isn't complete, You are only going to read. Here is your reading assignment.

Read the following link: http://mathbits.com/MathBits/Java/Looping/For.htm and experiment with for loops. Tomorrow (I should say today rather) I will try to post while loops and do-while loops. Enjoy and have fun!

2 Likes 1 Share

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 7:13am On Apr 23, 2016
I will be posting the while loop tutorial later on after I finish more of my project. Stay tuned! as you guys get more advanced with your Java skills, there will be a preparation for getting OCA Java Certified. OCA is Oracle Certified Associate Java Programmer SE 8. Eventually maybe sometime by June or July? I'd like us to start developing Android apps with Android studio.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 8:40am On Apr 23, 2016
macaranta:


Hi Fulaman,will you like to partner with our website to create(and possibly sell) programming courses using [url]macaranta.com[/url].??

Hello, I would love to be a partner with your website as I believe that education is important. When I have time I will join, but so many things are keeping me busy and occupied at the moment. I gracefully and humbly thank you for the offer and know that it is embedded within my heart. But right now, I can not sell programming courses because I don't have time to make 20 to 30 min videos on each subject. I will though eventually and will contact you promptly.
Re: Learning To Program With Java by the Fulaman by macaranta(m): 2:43pm On Apr 23, 2016
Fulaman198:


Hello, I would love to be a partner with your website as I believe that education is important. When I have time I will join, but so many things are keeping me busy and occupied at the moment. I gracefully and humbly thank you for the offer and know that it is embedded within my heart. But right now, I can not sell programming courses because I don't have time to make 20 to 30 min videos on each subject. I will though eventually and will contact you promptly.

Awesome,just let us know when you're ready.
Kind regards

1 Like

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (16) (Reply)

Java Vs PHP: Which Has The Brightest Future? / What Are The Best Laptops For Programmers And Hackers?! / Sultan Akintunde Set For Guinness World Record For Longest Software Coding Time

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 87
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.