Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,399 members, 7,808,432 topics. Date: Thursday, 25 April 2024 at 11:53 AM

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

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

Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 8:59am On Jun 06, 2016
ANTONINEUTRON:
My Code Is In This Link===> www.ideone.com/7n0z2M

Can't Copy it Here.

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

Waiting For Ur Review

Well I'm not going to give you a solution yet, but for starters there is no printIn method in the System class, it is println (or print line or print ln) it's a lowercase L instead of an I.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 9:02am On Jun 06, 2016
korlahwarleh:
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);




}

}


It's correct (briefly skimmed through it, but looks great), nicely done, you kind of took it a step further and instead asked the user for the number of tests they would ideally like to work it. Good job for going the extra km.
Re: Learning To Program With Java by the Fulaman by ANTONINEUTRON(m): 3:07pm On Jun 06, 2016
Fulaman198:


Well I'm not going to give you a solution yet, but for starters there is no printIn method in the System class, it is println (or print line or print ln) it's a lowercase L instead of an I.
Ok
Re: Learning To Program With Java by the Fulaman by Booyakasha(f): 3:17pm On Jun 06, 2016
nice job fulaman.. i love what you're doing, you should definitely be rewarded, but this is not how to teach sorry..
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 4:12pm On Jun 06, 2016
Booyakasha:
nice job fulaman.. i love what you're doing, you should definitely be rewarded, but this is not how to teach sorry..

Ok, how would you teach then?
Re: Learning To Program With Java by the Fulaman by Booyakasha(f): 7:16pm On Jun 06, 2016
Fulaman198:


Ok, how would you teach then?
lol, nevermind, i know it's not your fault, ŇL lacks code formatting functionality.. anyway, I'll love it if you become part of this great community i created.. wink
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 7:40pm On Jun 06, 2016
Booyakasha:

lol, nevermind, i know it's not your fault, ŇL lacks code formatting functionality.. anyway, I'll love it if you become part of this great community i created.. wink

Which community is that?
Re: Learning To Program With Java by the Fulaman by Nobody: 8:22pm On Jun 06, 2016
Booyakasha:
nice job fulaman.. i love what you're doing, you should definitely be rewarded, but this is not how to teach sorry..




It is 30th may 6th of june already, whatzup with ur promise?

1 Like

Re: Learning To Program With Java by the Fulaman by Booyakasha(f): 9:13pm On Jun 06, 2016
Fulaman198:

Which community is that?
crotonite:




It is 30th may 6th of june already, whatzup with ur promise?
I'll mention you guys in 30 minutes wink stay tuned..

1 Like

Re: Learning To Program With Java by the Fulaman by hardebayho(m): 9:31pm On Jun 06, 2016
Booyakasha:

I'll mention you guys in 30 minutes wink stay tuned..
Abeg, mention me too ooo
Re: Learning To Program With Java by the Fulaman by satmaniac(m): 7:33am On Jun 07, 2016
Fulaman198:


It's correct (briefly skimmed through it, but looks great), nicely done, you kind of took it a step further and instead asked the user for the number of tests they would ideally like to work it. Good job for going the extra km.

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."wink;
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 + ":"wink;
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!"wink;
Scores[i]--;
}




Scores[i]++;
total+=Scores[i];


}



average=total/Scores.length;
System.out.println("Your average is:" + " " + average);






}


}
Re: Learning To Program With Java by the Fulaman by Nobody: 8:39pm On Jun 07, 2016
satmaniac:


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:

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."wink;
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 + ":"wink;
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!"wink;

}






total+=Scores[i];


}



average=total/Scores.length;
System.out.println("Your average is:" + " " + average);






}


}




You tried very well.. Thumbs up but it would gv a logical error if the user inputs three values less than 3..


Look at inside the while statement that I would put into for loop






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."wink;
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 + ":"wink;
Scores[i] = stdio.nextInt();
//you should use || and not &&..
while (Scores[i]<=-1 || Scores[i]>100){
System.out.println("Score is less than zero, or greater than 100, please, enter a valid score!"wink;
Scores[i]=stdio.nextInt();
}






total+=Scores[i];


}



average=total/Scores.length;
System.out.println("Your average is:" + " " + average);






}


}
Re: Learning To Program With Java by the Fulaman by satmaniac(m): 9:19pm On Jun 07, 2016
pachman:


You tried very well.. Thumbs up but it would gv a logical error if the user inputs three values less than 3..


Look at inside the while statement that I would put into for loop






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."wink;
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 + ":"wink;
Scores[i] = stdio.nextInt();
//you should use || and not &&..
while (Scores[i]<=-1 || Scores[i]>100){
System.out.println("Score is less than zero, or greater than 100, please, enter a valid score!"wink;
Scores[i]=stdio.nextInt();
}






total+=Scores[i];


}



average=total/Scores.length;
System.out.println("Your average is:" + " " + average);






}


}

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?

1 Like

Re: Learning To Program With Java by the Fulaman by Nobody: 9:49pm On Jun 07, 2016
satmaniac:


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?
Lol,am also a beginner,just started classes and objects but i would start following op,he explains well,i have even saved his page sef
Re: Learning To Program With Java by the Fulaman by satmaniac(m): 10:27pm On Jun 07, 2016
pachman:
Lol,am also a beginner,just started classes and objects but i would start following op,he explains well,i have even saved his page sef

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.
Re: Learning To Program With Java by the Fulaman by Nobody: 10:41pm On Jun 07, 2016
satmaniac:


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.
Lol,i didnt start here,i started on my own but i would keep following
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 12:42am On Jun 08, 2016
satmaniac:


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.

You are right his code won't work because he used a while loop instead of an if conditional statement.

@pachman, did you happen to test your code. If you change one thing, it would work fine.
Re: Learning To Program With Java by the Fulaman by satmaniac(m): 9:17am On Jun 08, 2016
Fulaman198:


You are right his code won't work because he used a while loop instead of an if conditional statement.

@pachman, did you happen to test your code. If you change one thing, it would work fine.


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.
Re: Learning To Program With Java by the Fulaman by Nobody: 11:22am On Jun 08, 2016
Fulaman198:


You are right his code won't work because he used a while loop instead of an if conditional statement.

@pachman, did you happen to test your code. If you change one thing, it would work fine.
What i want is for the user to keep inputting the value until the user inputs the right value,while (user enter wrong value){enter the value again until he enters it right} I havent tested the code though,but av used this method before
Re: Learning To Program With Java by the Fulaman by Nobody: 7:33pm On Jun 08, 2016
Booyakasha:

I'll mention you guys in 30 minutes yrs time cheesy. stay tuned..




@fulaman198 i was reading a programming textbook and i came across something like this:

if(0 >= val ){...} instead of if(v <= 0){...} is there any advantange to using their method of if test?
Re: Learning To Program With Java by the Fulaman by Nobody: 9:33pm On Jun 08, 2016
crotonite:




@fulaman198 i was reading a programming textbook and i came across something like this:

if(0 >= val ){...} instead of if(v <= 0){...} is there any advantange to using their method of if test?
Both would work,it all depends on programming preference
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 11:43pm On Jun 08, 2016
crotonite:




@fulaman198 i was reading a programming textbook and i came across something like this:

if(0 >= val ){...} instead of if(v <= 0){...} is there any advantange to using their method of if test?

I prefer if (v <= 0){...} because it is better Programming vernacular (syntactically speaking) if that makes sense to you. Hardly do you ever see programmers use if ( 0 >= val ){...}

It's always a test for of variable to rest of the expression.

1 Like

Re: Learning To Program With Java by the Fulaman by Collinz2(m): 9:47pm On Jun 09, 2016
Is this code correct?

publick static void main(string[]args){
int user;
user =18;

if (user <= 18);
System.out.println("user is 18 or younger"wink;

else {
System.out.println("user is older than 18"wink;
}
}

if yes then why is eclipse telling me 'eles' has an exception?


MODIFIED: SOLVED.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 9:55pm On Jun 10, 2016
Guys one of my friends used Java as a means to parse some live data from the world bank site about forestation around the world. The data was parsed from a CSV file and put out in the form of an applet using the UnfoldingMaps API/library to illustrate the data in the csv file. I just wanted to show this to you to keep you motivated about some of the things you can do in Java.

3 Likes

Re: Learning To Program With Java by the Fulaman by hardebayho(m): 10:57pm On Jun 11, 2016
Fulaman198:
Guys one of my friends used Java as a means to parse some live data from the world bank site about forestation around the world. The data was parsed from a CSV file and put out in the form of an applet using the UnfoldingMaps API/library to illustrate the data in the csv file. I just wanted to show this to you to keep you motivated about some of the things you can do in Java.
Thanks bro

1 Like

Re: Learning To Program With Java by the Fulaman by satmaniac(m): 11:04pm On Jun 11, 2016
Fulaman198:
Guys one of my friends used Java as a means to parse some live data from the world bank site about forestation around the world. The data was parsed from a CSV file and put out in the form of an applet using the UnfoldingMaps API/library to illustrate the data in the csv file. I just wanted to show this to you to keep you motivated about some of the things you can do in Java.

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.
Re: Learning To Program With Java by the Fulaman by Collinz2(m): 1:54am On Jun 12, 2016
am not following the lessons here though, but multi-dimensional array is giving me headache.
Re: Learning To Program With Java by the Fulaman by hardebayho(m): 2:30am On Jun 12, 2016
Collinz2:
am not following the lessons here though, but multi-dimensional array is giving me headache.

Yeah bro, I feel your pain. I remember when I was also learning arrays and arraylists. Na that multidimensional array wan kill me...

But remember, when you're creating a multidimensional array, you're basically saying:

Create -rows and -columns. Like this:

int[][] x = new int[4] [3];

This statement will create an array of 4 rows and 3 columns.

So if you want to like assign a value to the first row and third column, you say x[0] [3] = 25; This will assign the value 25 to the first row and third column.

If you're also confused about rows and columns, check this out:

I checked for the meaning of row in my dictionary and dis is what I got:

A line of entries in a table, etc., going from left to right, as opposed to a column going from top to bottom

So if I have some numbers like this,

0 1 2 3 4 5 6 7 8 9

What row and column is 7? Basically, we have just one row in this block. So to represent this in Java, we write num[0][8] which is equivalent to 7.

I hope u understand sha.
Re: Learning To Program With Java by the Fulaman by Fulaman198(m): 7:09am On Jun 12, 2016
Collinz2:
am not following the lessons here though, but multi-dimensional array is giving me headache.

I think we will do multi-dimensional arrays before discussing methods, classes, etc.

1 Like 1 Share

Re: Learning To Program With Java by the Fulaman by Collinz2(m): 9:20am On Jun 12, 2016
Fulaman198:


I think we will do multi-dimensional arrays before discussing methods, classes, etc.
Thats great. I kinda understand it but when i compile the code i got exception error so i skip it and when i get to exception i will return to it.

One more thing, just like what pachman is asking. For instance using the indexOf to check for @ in an email, i wrote the code and add user input scanner and the if statement. If the user enter an email without the @ it wil return invalid email as i instructed java to do, so How do i tell java to tell the user to keep inputing the email until he got it correct.

1 Like

Re: Learning To Program With Java by the Fulaman by hardebayho(m): 1:50pm On Jun 12, 2016
Collinz2:
Thats great. I kinda understand it but when i compile the code i got exception error so i skip it and when i get to exception i will return to it.

One more thing, just like what pachman is asking. For instance using the indexOf to check for @ in an email, i wrote the code and add user input scanner and the if statement. If the user enter an email without the @ it wil return invalid email as i instructed java to do, so How do i tell java to tell the user to keep inputing the email until he got it correct.
You use a while loop
Re: Learning To Program With Java by the Fulaman by Collinz2(m): 5:53pm On Jun 12, 2016
hardebayho:

You use a while loop
i try manipulating the while loop even do while loop nothing happen, even when it work if i inser the right input it wil stil loop again.

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

Java Vs PHP: Which Has The Brightest Future? / The Top Highly Paid Programming Languages To Learn / What Are The Best Laptops For Programmers And Hackers?!

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