Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,148,770 members, 7,802,357 topics. Date: Friday, 19 April 2024 at 12:59 PM

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

Nairaland Forum / Science/Technology / Programming / Learning To Program With Java by the Fulaman (41217 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) ... (8) (9) (10) (11) (12) (13) (14) ... (16) (Reply) (Go Down)

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 4:16pm On May 29, 2016
elpedro:
I've always seen Java's long codes on small tasks to be a pain in the butt.. Though I have a Hardcopy Textbook, ''Java, How to Program'' by Paul/Harvey Deitel, I still find it hard to like it as a choice of language...

@Fulaman198, How can I adapt or start using this language fluently... I've seen that its productivity rate(based on usefulness) is quite high as one can develop good desktop and mobile apps with it.. I have to make a choice between Java and Python...

I've seen the GUI part in the textbook and I was like, ''whadda eff''... Long lines of code to create a simple GUI.. I guess that's why most peeps find it difficult on training emselves on Java...

My question is: In what ways should I approach Java so as to fully understand the concepts and embrace it without minding its ugliness...??

It's all about persistence and never giving up. You must have that ambition to be strong and to never accept defeat. Having the courage to approach any problem with an I do it mentality.

Java is one of the harder high-level languages, I know but C++ and C# are also in that category as well. Java is a great language though used for Android app development and great for parsing data into data structures. There is so much to cover in Java. It's not something you learn in just a months time. You just have to keep pushing yourself through it.

1 Like

Re: Learning To Program With Java by the Fulaman by ANTONINEUTRON(m): 5:50pm On May 29, 2016
Fulaman198:

Sorry youngster, I'm semi back
Then Semi Welcome grin
When u come back fully,.. wink U Knw wink

1 Like

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 4:40am On May 30, 2016
crotonite:
angry

LOL angry face Crotonite
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 4:43am On May 30, 2016
Dekatron:
hey fulaman198... I actually just saw the day whatever assignment..... so I tried it and go it within not up to 15 mins(including watching musical videos simultaneously.... I am notorious for not always commenting on my codes.....do accept my "laziness"...and I already started typing away before I remembered I should use "switch" statements instead of multiple IFs.......also, I wrote my code and ran ONCE.....Not gloating sha ooo undecided grin grin grin grin lipsrsealed lipsrsealed lipsrsealed















import java.util.Scanner;
public class FulaAssignment {

@SuppressWarnings("resource"wink
public static void main(String[] args) {
Scanner length = new Scanner (System.in);
Scanner selector = new Scanner (System.in);
Scanner distance = new Scanner (System.in);
Scanner temperature = new Scanner (System.in);
Scanner currency = new Scanner (System.in);
float cm;
int select=5;
double inch;
float m;
double ft;
float cel;
double fahr;
float naira;
double euro;
System.out.println("Input a number: "wink;
select = selector.nextInt();
while (select < 5) {
if (select == 1) {

System.out.println("Enter the value of 'cm' to be converted to 'inch': "wink;
cm = length.nextFloat();
inch = cm/2.54;
System.out.println("The value of " + cm+"cm" + "in inches is:" +inch);
System.out.println();
}
else if (select == 2){
System.out.println("Enter the value of 'ft' to be converted to 'm': "wink;
m = distance.nextFloat();
ft = m * 3.28;
System.out.println("The value of" +m+"M" + " in feet is:" + ft);
System.out.println();
}
else if (select == 3){
System.out.println("Enter the value of 'C' to be converted to Fahrenheit"wink;
cel = temperature.nextFloat();
fahr = (1.cool* cel + 32;
System.out.println("The value of" + cel+"degrees" + " in Fahrenheit is: " + fahr);
System.out.println();
}
else if (select == 4) {

System.out.println("Enter the amount of Naira to be converted to Euros: "wink;
naira = currency.nextFloat();
euro = naira/227.96;
System.out.println("The amount of " + naira+"N" + " in Euro is: " + euro);
System.out.println();
}
else if (select == 5){

System.out.println("Exiting now. . . . "wink;
System.exit(0);

}
select++;
}

}

}

Hello, your assignment is correct for the most part except that it does not completely follow the instructions. If I were a complete newb user trying to use your programme, how would I know what to press? Thus, the instructions ask for you the programmer to display a list for the user to select some options. Typically speaking, a Switch-Case structure is the best way to approach this. So it would look something like this.

Output:

1. Do Action 1
2. Do Action 2
3. Do Action 3
4. Do Action 4
5. Exit Programme

I hope that helps.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 4:49am On May 30, 2016
Day 6:

Hello everyone and welcome to day 6 of the tutorial Learning to programme in Java with the Fulani herdsman (I joke). Welcome to learning to programme in Java with the Fulaman. Today, very early in the morning, we will be discussing arrays and their respective significance.

Often in Computing, we want to look for ways to hold a vast amount of information, more succinctly put, to store a large amount of data like in a data set for instance. Assume your boss one day gives you a spreadsheet full of data and asks you to parse the information from the Excel spreadsheet into a Java programme. One could use a Hashmap, an Array List or even an array (though it would be a bit more difficult).

The purpose of an array is to store data. Think back to the previous tutorials in which we have stored things like exam scores to an integer. Let's assume that I have 4 students, and I want to store 10 integer test scores to each respective student? How would I go about doing that? Before we address that issue, I would like to go over some basic concepts about arrays first.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 4:49am On May 30, 2016


In the image above, what we see is how a simple array looks like. An array is comprised of indicies in which the starting index is 0. So if I have an array of 10 things, the starting index is 0 and the ending index is 9. As shown in the picture.

Going back to what I said earlier about exam scores. Let us assume we have a student who goes by the name Ahmadu and another student who goes by the name Halimatu (these are just examples, if your name is Ahmadu or Halimatu, I apologize as you may not be happy with the following test scores smiley ).

I have 10 scores for Halimatu and ten scores for Ahmadu. In an array it would look something like this:
Re: Learning To Program With Java by the Fulaman by Dekatron(m): 5:02am On May 30, 2016
Fulaman198:


Hello, your assignment is correct for the most part except that it does not completely follow the instructions. If I were a complete newb user trying to use your programme, how would I know what to press? Thus, the instructions ask for you the programmer to display a list for the user to select some options. Typically speaking, a Switch-Case structure is the best way to approach this. So it would look something like this.

Output:

1. Do Action 1
2. Do Action 2
3. Do Action 3
4. Do Action 4
5. Exit Programme

I hope that helps.


I know that... But I already started typing before I could think of that... Besides, the if statement is more like the case too.....

Also, the program problem says : the user would input a number from 1-5..that means the user already knows details about the program because he knows he has to input from a number to another.



Thanks though .. I will modify if I can (my PC spoilt 15' after I uploaded this)
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 5:03am On May 30, 2016
student Ahmadu: In index 0 would have a score of 50, in index 1, a score of 48, and in index 2 a score of 65 and so on until we get to index 9 as it is the 10th number in the array in the 9th index.

For student Halimatu: In index 0, she's a better student than Ahmadu and Ahmadu envies her for that, index 0 = 65, index 1 = 62, index 3 = 64 and so on. In an array table it would look something like what we see below

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 5:12am On May 30, 2016
Each index represents the respective test score for each student. What I have illustrated in the screen shot in Java is referred to as an array of integers. There are many ways to initialize the data that was shown earlier in Java. I will demonstrate two key ways on how to add values in an array and how to declare arrays.

1 Like

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 5:16am On May 30, 2016
In the screenshot above, I have declared 2 arrays of type 'int'. As you can see, whenever you declare an array, you need brackets. In Java, when declaring an array, it's always a good idea to place those brackets after the data type (e.g. int [] or double[]).

As one can also see, I have assigned and initialized 10 score values to each student. This is not the only way to initialize an array but in my opinion it is one of the easier ways. Another way of initializing an array will be in the next post.

1 Like

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 5:34am On May 30, 2016
Take a look at the programme below and the details discussed in the programme

As one can see, the other way of creating an array is declaring an array of a specified type and assigning it to a particular size. You can then assign individual values to the elements of the array with the following syntax:



datatype myVariable[index number] = whatever; to be more specific
int myNums[0] = 100; //initializing first element of array myNums to 100

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 5:35am On May 30, 2016
If you guys can't see the previous image, please save it and open it on your respective computers.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 5:46am On May 30, 2016
Let's say I wanted to loop through all the test scores for each student and display them one at a time? How would I go about doing that? Well we'll use Halimatu for this instance because I don't think Ahmadu would be too pleased if we displayed his mediocre scores grin

Often, the best way to loop through an array is with a for loop iteration structure (which we discussed in a previous tutorial).

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 5:49am On May 30, 2016
In case you can't read it, the text highlighted in yellow with a box is 'i' which was initialized as an int in the for loop. We are looping through all her test scores here until i is less than the length of the array (which is 10). Therefore, we are starting at index 0 which if you recall is the beginning of all arrays and ending at index 9.

Re: Learning To Program With Java by the Fulaman by satmaniac(m): 8:03am On May 30, 2016
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?
Re: Learning To Program With Java by the Fulaman by jimklef(m): 3:14pm On May 30, 2016
ANTONINEUTRON:

Ok!!
I failed.

But your new assignment is hard ,
Google couldn't provide anything tangible.
A article regarding the assignment will help.

but u can find it on codeproject.com, or i can send u the source code on whatsapp
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 9:34pm On May 30, 2016
satmaniac:
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?

Hey my friend, I'll check it out
Re: Learning To Program With Java by the Fulaman by ANTONINEUTRON(m): 10:32pm On May 30, 2016
satmaniac:
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?
L gringrin L

1 Like

Re: Learning To Program With Java by the Fulaman by ANTONINEUTRON(m): 10:41pm On May 30, 2016
jimklef:


but u can find it on codeproject.com, or i can send u the source code on whatsapp
ChecK Out my new code on page.7.

Is it ok??
Re: Learning To Program With Java by the Fulaman by satmaniac(m): 1:57pm On May 31, 2016
Fulaman198:


Hey my friend, I'll check it out

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.
Re: Learning To Program With Java by the Fulaman by satmaniac(m): 2:17pm On May 31, 2016
ANTONINEUTRON:

L gringrin L

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 cheesy see? na emmpty oo!
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 4:29pm On May 31, 2016
satmaniac:


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 cheesy see? na emmpty oo!

I'll post the assignment soon
Re: Learning To Program With Java by the Fulaman by satmaniac(m): 9:10pm On Jun 01, 2016
ANTONINEUTRON see wetin u don cause? Now him wan push bone come give us. Fear don catch me already.


Fulaman198:


I'll post the assignment soon
Re: Learning To Program With Java by the Fulaman by ANTONINEUTRON(m): 6:58am On Jun 02, 2016
satmaniac:
ANTONINEUTRON see wetin u don cause? Now him wan push bone come give us. Fear don catch me already.


Oo Bwoy!!!

Assignment Don Show Now Now [like Vandamme]
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 7:31pm On Jun 02, 2016
Hello ladies and gentlemen, before I post the assignment, I wanted to know how many of you are using an IDE (e.g. Netbeans, Eclipse, IntelliJ, etc.) I wanted to demonstrate a fun but small GUI project for you guys to keep you all motivated to learn Java that I would have you guys do. But in order to do so, you guys need an IDE.

I personally recommend Netbeans: https://netbeans.org/features/java/index.html

But I don't care if you use Eclipse or IntelliJ

Eclipse - http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/keplersr1
IntelliJ - https://www.jetbrains.com/idea/#chooseYourEdition
Re: Learning To Program With Java by the Fulaman by Nobody: 7:59pm On Jun 02, 2016
I can't wait to see the surprise teacher has for us.

1 Like

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 7:31am On Jun 03, 2016
First of two assignments on Arrays:
Level of Difficulty on a scale of 1 - 5: 3

Based on what you know thus far about arrays, create a programme grabs the input of 10 test scores. No test score can be below 0! If the user enters a value less than 0, inform the user that they must not enter a value less than 0. Each test score will be saved to an array of type int where each score occupies an index within the array. The objective of this programme is to take all 10 test scores that the user has input into the array and find the average of all 10 test scores and report it back to the user. (Please let me know if you need further clarification as to what I want on this assignment).

Optional reading: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

Hint: To get the number of elements in an array in Java, you use the
arrayName.length
method. You can use this as a substitution for 10 (which is the number of tests). So the formula would look like - (total of test scores / arrayName.length ). It's totally up to you on how you would like to implement the calculation for finding the average. However, if you were to write a much larger program that scales in which you don't know the number of tests, the aforementioned method is the best way to do it.

I will post the 2nd assignment soon. I still want to know if people here are using IDEs for their respective assignments.

Output for the first programme should look something like the screenshots below and should test for numbers less than 0:

1 Like

Re: Learning To Program With Java by the Fulaman by joey150(m): 9:44am On Jun 03, 2016
Any practical video tutorial or interactive software to learn this thing on?

This way makes me learn way slower..plus my phone drains like crazy plus epipleptic power supply.

Good job to the o.p.
Re: Learning To Program With Java by the Fulaman by Nobody: 2:24pm On Jun 03, 2016
MY SOLUTION...

Re: Learning To Program With Java by the Fulaman by ANTONINEUTRON(m): 12:29pm On Jun 05, 2016
My Code Is In This Link===> www.ideone.com/a2dqw1

Can't Copy it Here.

??!!5 Errors Regarding Package Involve!!??

Waiting For Ur Review
Re: Learning To Program With Java by the Fulaman by korlahwarleh: 8:47pm On Jun 05, 2016
Pls pardon me i have been a ghost learner on this thread. i am learning Java also.

this is my own assignment, i hope its correct




import java.util.Scanner;
public class Practice {

public static void main(String[] args) {
// TODO code application logic here

//Recieve test scores from the user
Scanner input = new Scanner(System.in);
System.out.print("How many test scores do you want to work with: "wink;
int testScores = input.nextInt();
//test scores is the number of scores you want to work with. 10 in this case
int scores[] = new int[testScores];
int total =0;
for (int counter = 0; counter < scores.length; counter ++)

{

System.out.print("Please enter Test Score " + (counter + 1) + ":"wink;

scores[counter] = input.nextInt();
if(scores[counter] < 0)
System.out.println("Please enter a valid No"wink;

total +=scores[counter];
}

double average = total/scores.length;


System.out.println("Student's average is " + average);




}

}
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 8:57am On Jun 06, 2016
crotonite:
MY SOLUTION...

Good, I noticed that you used a helper method in your own version of this assignment, a bit different from how I did it, but it's great nonetheless. Good job.

1 Like

(1) (2) (3) ... (8) (9) (10) (11) (12) (13) (14) ... (16) (Reply)

Facebook Is Suing Me For This / The Top Highly Paid Programming Languages To Learn / Java Vs PHP: Which Has The Brightest Future?

Viewing this topic: 2 guest(s)

(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. 70
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.