Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,197,929 members, 7,966,441 topics. Date: Friday, 04 October 2024 at 02:41 PM |
Nairaland Forum / Okunade's Profile / Okunade's Posts
(1) (2) (of 2 pages)
Travel / Re: Preparing For PTE? Get In Here by okunade(m): 12:33pm On Dec 07, 2018 |
Hello everyone, I need PTE exam voucher. Please contact me if you have. Thanks |
Travel / Re: Preparing For PTE? Get In Here by okunade(m): 11:45am On Apr 23, 2018 |
okunade: I think he's @majiouk2002 |
Travel / Re: Preparing For PTE? Get In Here by okunade(m): 11:41am On Apr 23, 2018 |
I really appreciate Rasheed Adewale, he got me registered by providing me a PTE voucher without stress. He is trustworthy and respond faster. Just got my voucher from him through WhatsApp. I pray and wish I score 90 in all modules. |
Politics / Re: Ngozi Okonjo-Iweala Celebrates 61st Birthday Today by okunade(m): 9:08am On Jun 13, 2015 |
NGO baby |
Programming / Re: Electronic Circuit Design And Construction-join The Team by okunade(m): 5:48am On Jul 22, 2012 |
This is good. Name: Okunade Habeeb Location: OAU, Ife Email: guessy2k2@yahoo.com Skills: Java Programming (Professional) C/C++ (Professional) Oracle RDMS (Professional) MikroBasic (Professional) PIC/PLC |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 4:51pm On Dec 26, 2009 |
hi |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 2:24pm On Nov 28, 2009 |
Hi Good ideas thanks somebody should copy all the lesson to microsoft word and send it anyway lesson continues |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 5:20pm On Jun 30, 2009 |
everything is ok |
Programming / Re: Let Share Codes by okunade(m): 12:10pm On May 18, 2009 |
go to java.sun.com |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 10:13am On May 14, 2009 |
Everything is OK |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 1:08pm On May 04, 2009 |
hi zub, im not in school now, but on IT. when I come back I will call you. |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 1:14pm On Apr 28, 2009 |
ok I have seen the assignment Im writing exam now when I finish I will continue to post, just try to learn yourself follow javaprince instruction till I come back bye |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 12:39pm On Apr 03, 2009 |
Lesson 5…, Mixed Data Types, Casting, and Constants So far we have looked mostly at simple cases in which all the numbers involved in a calculation were either all integers or all doubles. Here, we will see what happens when we mix these types in calculations. Java doesn’t like to lose data: Here is an important principle to remember: Java will not normally store information in a variable if in doing so it would lose information. Consider the following two examples: 1. An example of when we would lose information: double d = 29.78; int i = d; //won’t compile since i is an integer and it would have to chop-off // the .78 and store just 29 in i….thus, it would lose information. There is a way to make the above code work. We can force compilation and therefore result in 29.78 being “stored” in i as follows (actually, just 29 is stored since i can only hold integers): int i = (int)d; //(int) “casts” d as an integer… It converts d to integer form. 2. An example of when we would not lose information: int j = 105; double d = j; //legal, because no information is lost in storing 105 in the // double variable d. The most precise: In a math operation involving two different data types, the result is given in terms of the more precise of those two types…as in the following example: int i = 4; double d = 3; double ans = i/d; //ans will be 1.33333333333333…the result is double precision 20 + 5 * 6.0 returns a double. The 6.0 might look like an integer to us, but because it’s written with a decimal point, it is considered to be a floating point number…a double. Some challenging examples: What does 3 + 5.0/2 + 5 * 2 – 3 return? 12.5 What does 3.0 + 5/2 + 5 * 2 – 3 return? 12.0 What does (int)(3.0 + 4)/(1 + 4.0) * 2 – 3 return? -.2 Don’t be fooled: Consider the following two examples that are very similar…but have different answers: double d = (double)5/4; //same as 5.0 / 4…(double) only applies to the 5 System.out.println(d); //1.25 int j = 5; int k = 4; double d = (double)(j / k); //(j / k) is in its own little “world” and performs //integer division yielding 1 which is then cast as //a double, 1.0 System.out.println(d); //1.0 Constants: Constants follow all the rules of variables; however, once initialized, they cannot be changed. Use the keyword final to indicate a constant. Conventionally, constant names have all capital letters. The rules for legal constant names are the same as for variable names. Following is an example of a constant: final double PI = 3.14159; The following illustrates that constants can’t be changed: final double PI = 3.14159; PI = 3.7789; //illegal When in a method, constants may be initialized after they are declared. final double PI; //legal PI = 3.14159; Constants can also be of type String, int and other types. final String NAME= “Peewee Herman”; final int LUNCH_COUNT = 122; Project… Mixed Results Create a new project called MixedResults with a class called Tester. Within the main method of Tester you will eventually printout the result of the following problems. However, you should first calculate by hand what you expect the answers to be. For example, in the parenthesis of the first problem, you should realize that strictly integer arithmetic is taking place that results in a value of 0 for the parenthesis. double d1 = 37.9; //Initialize these variables at the top of your program double d2 = 1004.128; int i1 = 12; int i2 = 18; Problem 1: 57.2 * (i1 / i2) +1 Problem 2: 57.2 * ( (double)i1 / i2 ) + 1 Problem 3: 15 – i1 * ( d1 * 3) + 4 Problem 4: 15 – i1 * (int)( d1 * 3) + 4 Problem 5: 15 – i1 * ( (int)d1 * 3) + 4 Your printout should look like the following: Problem 1: 1.0 Problem 2: 39.13333333333333 Problem 3: -1345.39999999999 Problem 4: -1337 Problem 5: -1313 Exercise on Lesson 5 Unless otherwise instructed in the following problems, state what gets printed. 1. Write code that will create a constant E that’s equal to 2.718. 2. Write the simplest type constant that sets the number of students, NUM_STUDENTS, to 236. 3. What’s wrong, if anything, with the following code in the main method? final double Area; Area = 203.49; 4. int cnt = 27.2; System.out.println(cnt); What’s printed? 5. double d = 78.1; int fg = (int)d; System.out.println(fg); What’s printed? 6. Is double f4 = 22; legal? 7. The following code stores a 20 in the variable j: double j = 61/3; What small change can you make to this single line of code to make it print the “real” answer to the division? 8. System.out.println( (double)(90/9) ); 9. System.out.println(4 + 6.0/4 + 5 * 3 – 3); 5-4 10. int p = 3; double d = 10.3; int j = (int)5.9; System.out.println(p + p * d – 3 * j); 11. int p = 3; double d = 10.3; int j = (int)5.9; System.out.println(p + p * (int)d – 3 * j); The following code applies to 12 – 15: int dividend = 12, divisor = 4, quotient = 0, remainder = 0; int dividend2 = 13, divisor2 = 3, quotient2 = 0, remainder2 = 0; quotient = dividend/divisor; remainder = dividend % divisor; quotient2 = dividend2 / divisor2; remainder2 = dividend2 % divisor2; 12. System.out.println(quotient); 13. System.out.println(remainder); 14. System.out.println(quotient2); 15. System.out.println(remainder2); 16. Write a line of code in which you divide the double precision number d by an integer variable called i. Type cast the double so that strictly integer division is done. Store the result in j, an integer. 17. Suppose we have a line of code that says final String M = “ugg”; Later in the same program, would it be permissible to say the following? M = “wow”; |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 12:09pm On Apr 03, 2009 |
Lesson 4…, Using Numeric Variables, The assignment operator: The assignment operator is the standard equal sign (=) and is used to “assign” a value to a variable. int i = 3; // Ok,…assign the value 3 to i. Notice the direction of data flow. 3 = i; // Illegal! Data never flows this way! double p; double j = 47.2; p = j; // assign the value of j to p. Both p and j are now equal to 47.2 Multiple declarations: It is possible to declare several variables on one line: double d, mud, puma; //the variables are only declared double x = 31.2, m = 37.09, zu, p = 43.917; //x, m, & p declared and initialized // zu is just declared Fundamental arithmetic operations: The basic arithmetic operation are +, -, * (multiplication), / (division), and % (modulus). Modulus is the strange one. For example, System.out.println(5%3); will print 2. This is because when 5 is divided by 3, the remainder is 2. Modulus gives the remainder. Modulus also handles negatives. The answer to a%b always has the same sign as a. The sign of b is ignored. PEMDAS: The algebra rule, PEMDAS, applies to computer computations as well. (PEMDAS stands for the order in which numeric operations are done. P = parenthesis, E = exponents, M = multiply, D = divide, A = add, S = subtract. Actually, M and D have equal precedence, as do A and S. For equal precedence operation, proceed from left to right. A mnemonic for PEMDAS is, “Please excuse my dear Aunt Sally”… See Appendix H for the precedence of all operators.) System.out.println(5 + 3 * 4 –7); //10 System.out.println(8 – 5*6 / 3 + (5 –6) * 3); //-5 Not the same as in Algebra !!!: An unusual assignment….consider the following: count = count +3; //this is illegal in algebra; however, in computer science it //means the new count equals the old count + 3. int count =15; count = count + 3; System.out.println(count); //18 Increment and Decrement: The increment operator is ++, and it means to add one. The decrement operator is --, and it means to subtract one: x++; means the same as x = x +1; x--; means the same as x = x – 1; x++ is the same as ++x (the ++ can be on either side of x) x-- is the same as --x (the -- can be on either side of x) int y = 3; y++; System.out.println(y); //4 Compound operators: Syntax Example Simplified meaning a. += x += 3; x = x + 3; b. -= x -= y - 2; x = x – (y - 2); c. *= z*= 46; z = z * 46; d. /= p/= x-z; p = p / (x-z); e. %= j%= 2 j = j%2; Code Examples int g = 409; g += 5; System.out.println(g); //414 double d = 20.3; double m =10.0; m*=d –1; System.out.println(m); //193.0 The whole truth: Actually, the full truth was not told above concerning x++. It does not always have the same effect as does ++x. Likewise, x-- does not always have the same effect as does --x. x++ increments x after it is used in the statement. ++x increments x before it is used in the statement. Similarly, x-- decrements x after it is used in the statement. --x decrements x before it is used in the statement. Code Examples int q = 78; int p = 2 + q++; System.out.println(“p = ” + p + “, q = ” + q); //p = 80, q = 79 int q = 78; int p = ++q + 2; System.out.println(“p = ” + p + “, q = ” + q); //p = 81, q = 79 Integer division truncation: When dividing two integers, the fractional part is truncated (thrown away) as illustrated by the following: int x = 5; int y = 2; System.out.println(x / y); //Both x and y are integers so the “real” answer of 2.5 //has the fractional part thrown away to give 2 Exercise on Lesson 4 Unless otherwise directed in the following problems, state what is printed. Some of these problems may have incorrect syntax and in those cases you should answer that the code would not compile. 1. int h = 103; int p =5; System.out.println(++h + p); System.out.println(h); 2. Give three code examples of how to increment the integer j by 1. 3. double def; double f = 1992.37; def = f; System.out.println(def); 4. Write a single line of code that will print the integer variable zulu and then decrement its value by 1. 5. int a = 100; int b = 200; b/=a; System.out.println(b + 1); 6. Write a single line of code that uses the compound operator, -=, to subtract p-30 from the integer value v and store the result back in v. 7. Write a single line of code that does the same thing as #6 but without using - =. 8. int p = 40; int q = 4; System.out.println(2 + 8 * q / 2 - p); 9. int sd = 12; int x = 4; System.out.println( sd%(++x) ); System.out.println(x); 10. int g; 3 = g; System.out.println(++g*79); What is the result? 11. On a single line of code declare m, b, and f to be double and on that same line initialize them all to be 3.14. 12. On a single line of code declare x, y, and z all to be of integer type. 13. int m = 36; int j = 5; m = m / j; // new m is old m divided by j System.out.println(m); What’s printed? 14. System.out.println(3/4 + 5*2/33 –3 +8*3); What’s printed? 15. What is the assignment operator? 16. Write a statement that stores the remainder of dividing the variable i by j in a variable named k. 17. int j = 2; System.out.println(7%3 + j++ + (j – 2) ); 18. Show three different ways to decrement the variable j. Project… Cheating on Your Arithmetic Assignment Create a new project called ArithmeticAssignment with a class called Tester that will calculate and print the results of the following arithmetic problems: 79 + 3 * (4 + 82 –68) – 7 +19 (179 +21 +10) / 7 + 181 10389 * 56 * 11 + 2246 The printout should look like the following: 79 + 3 * (4 + 82 - 68) -7 + 19 = 145 (179 + 21 + 10) / 7 + 181 = 211 10389 * 56 * 11 + 2246 = 6401870 |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 1:19am On Mar 23, 2009 |
hi i'm back Lesson 4 coming soon |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 5:37pm On Mar 13, 2009 |
LESSON THREE Simple String Operations In this lesson we will learn just a few of the things we can do with Strings. 1. Concatenation: First and foremost is concatenation. We use the plus sign, +, to do this. For example: String mm = "Hello"; String nx = "good buddy"; String c = mm + nx; System.out.println(c); //prints [color=#990000]Hellogood buddy…notice no space between o & g [/color] The above code could also have been done in the following way: String mm = "Hello"; String nx = "good buddy"; System.out.println(mm + " " + nx); //prints [color=#990000]Hello good buddy…notice the space [/color] We could also do it this way: System.out.println("Hello" + " good buddy" // prints Hello good buddy 2. The length method: Use the length( ) method to find the number of characters in a String: (NOTE the word METHOD*) String theName = "Donald Duck"; int len = theName.length( ); System.out.println(len); //prints 11…[color=#990000]notice the space gets counted [/color] Right now we don’t see much value in this length thing…just wait! A piece of a String (substring): We can pick out a piece of a String…substring String myPet = "Sparky the dog"; String smallPart = myPet.substring(4); System.out.println(smallPart); //prints [color=#990000]ky the dog [/color] Why do we get this result? The various characters in a String are numbered starting on the left with 0. These numbers are called indices. (Notice the spaces are numbered too.) S p a r k y t h e d o g … so now we see that the ‘k’ has index 4 and we go from 0 1 2 3 4 5 6 7 8 9 10 11 12 13 k all the way to the end of the string to get “ky the dog”. A more useful form of substring: But wait! There’s another way to use substring String myPet = "Sparky the dog"; String smallPart = myPet.substring(4, 12); System.out.println(smallPart); //prints [color=#990000]ky the d [/color] How do we get ky the d? Start at k, the 4th index, as before. Go out to the 12th index, 'o' in this case and pull back one notch. That means the last letter is d. Conversion between lower and upper case: 1. toLowerCase converts all characters to lower case (small letters) String bismark = "Dude, where’s MY car?"; System.out.println( bismark.toLowerCase( ) ); // prints dude, where’s my car? 2. toUpperCase converts all characters to upper case (capital letters) System.out.println( "Dude, where’s My car?".toUpperCase( ) ); //prints DUDE, WHERE’S MY CAR? Note: length, substring, toLowerCase, and toUpperCase are all methods of the String CLASS There are other methods we will learn later. Concatenating a String and a numeric: It is possible to concatenate a String with a numeric variable as follows: int x = 27; String s = "What have we done?" String combo = s + " " + x; System.out.println(combo); //prints What have we done? 27 Escape sequences: How do we force a quote character (") to printout…. or, to be part of a String. Use the escape sequence, \", to print the following (note escape sequences always start with the \ character… more on escape sequences later): What "is" the right way? String s = "What \"is\" the right way?"; System.out.println(s); //prints What "is" the right way? Another escape sequence, \n, will create a new line (also called line break) as shown below: String s = "Here is one line\nand here is another."; System.out.println(s); Prints the following: Here is one line and here is another. The escape sequence, \\, will allow us to print a backslash within our String. Otherwise, if we try to insert just a single \ it will be interpreted as the beginning of an escape sequence. System.out.println("Path = c:\\Program_file.doc" Prints the following: Path = c:\Program_file.doc The escape sequence, \t, will allow us to “tab” over. The following code tabs twice. System.out.println(“Name:\t\tAddress:”); Prints the following: Name: Address: ----------------------------------------------------------------------------------------------------------------------------- EXERCISE ON LESSON THREE, 1. Write code in which a String variable s contains “The number of rabbits is”. An integer variable argh has a value of 129. Concatenate these variables into a String called report. Then print report. The printout should yield: The number of rabbits is 129. *Note that we want a period to print after the 9. 2. What is the output of System.out.println( p.toUpperCase( ) ); if p = “Groovy Dude”? 3. Write code that will assign the value of “Computer Science is for nerds” to the String variable g. Then have it print this String with nothing but “small” letters. 4. What will be the value of c? String c; String m = “The Gettysburg Address”; c = m.substring(4); 5. What will be the value c? String b = “Four score and seven years ago,”; c = b.substring(7, 12); 6. What is the value of count? int count; String s = “Surface tension”; count = s.length( ); 7. Write code that will look at the number of characters in String m = “Look here!”; and then “Look here!” has 10 characters. *Note Use the length( ) method to print the 10 ….you must also force the two quotes to print. 8. How would you print the following? All “good” men should come to the aid of their country. 9. Write code that will produce the following printout using only a single println( ). Hello Hello again 10. Write code that will produce the following printout. A backslash looks like this \, …right? 11. What is output by the following? String pq = “Eddie Haskel”; int hm = pq.length( ); String ed = pq.substring(hm - 4); System.out.println(ed); 12. Which character is at the 5th index in the String “Herman Munster”? PROJECT, … Name that Celebrity Create a new project called NameThatCelebrity in which only partially recognizable names of celebrities are to be produced. In a real implementation of this game, the idea is for a contestant to be able to guess the real name of the celebrity after the first two and last three letters are dropped from the name. We have been given the task of testing the feasibility of this idea by producing the following printout: Allan Alda>>>lan A John Wayne>>>hn Wa Gregory Peck>>>egory P Begin your code within the main method as follows: String s1 = “Allan Alda”; String s2 = “John Wayne”; String s3 = “Gregory Peck”; Apply the length and substring methods to these Strings to produce the above printout. |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 8:37am On Mar 13, 2009 |
Im very happy for you azpunpin, if you continue like this you will be a great programmer. All the ans are correct, but except question 8, 9, 10 note there is a different between declaring a variable and initializing a variable. //Declaration double pay; // I've only declared pay as type double //Initialization pay = 50.50; // pay was initialized to a double value 50.50 so number 8. { int count; // Answer, Don't initialize } number 9. { bankBalance = 136.05; // Assume it has already been declared. } number 10. doubled & scooter13 Note: I will post all the java keyword that cannot be used as a variable name. I will also post Lesson 3 tonight INSHA Allah |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 1:02am On Mar 13, 2009 |
hi mr staroye follow the tutorial from lesson one, read it carefully, and do all the assignment. hey JACOB05 THIS THREAD MAY NOT BE FOR YOU, BUT NOVICE IN JAVA OK |
Programming / Re: Study Group For C++ Learner by okunade(m): 10:13pm On Mar 11, 2009 |
Yes I know a little bit about C++ Since Im good in JAVA im willing to join My task? |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 9:18pm On Mar 11, 2009 |
LESSON TWO, Variable Types (String, int, double) Three variable types: (A good way to learn the following points is to modify the code of the "Hello World" program according to the suggestions below.) 1. String….used to store things in quotes….like "Hello world" Sample code: [color=#000099] public static void main(String args[]) { String s = "Hello cruel world"; System.out.println(s); } 2. int ….used to store integers (positive or negative) Sample code: public static void main(String args[]) { int age = 59; System.out.println(age); } 3. double ….used to store "floating point" numbers (decimal fractions). double means "double precision". Sample code: public static void main(String args[]) { double d = -137.8036; System.out.println(d); d = 1.45667E23; //Scientific notation…means 1.45667 X 10+23 } Declaring and initializing: When we say something like double x = 1.6; we are really doing two things at once. We are declaring x to be of type double and we are initializing x to the value of 1.6. All this can also be done in two lines of code (as shown below) instead of one if desired: double x; //this declares x to be of type double x = 1.6; //this initializes x to a value of 1.6 What’s legal and what’s not: int arws = 47.4; //illegal, won’t compile since a decimal number cannot “fit” into an integer variable. double d = 103; //legal…same as saying the decimal number 103.0 Rules for variable names: 1. Variable names must begin with a letter (or an underscore character) and cannot contain spaces. 2. The only “punctuation” character permissible inside the name is the underscore (“_”). 3. Variable names cannot be one of the reserved words (key words…)that are part of the Java language. Legal names Illegal names Agro 139 D 139Abc d31 fast One hoppergee class hopper_gee slow.Sally largeArea double goldNugget gold;Nugget hopper-gee Variable naming conventions: It is traditional (although not a hard and fast rule) for variable names to start with a lower case letter. If a variable name consists of multiple words, combine them in one of two ways: bigValue… jam everything together. First word begins with a small letter and subsequent words begin with a capital. big_value… separate words with an underscore. ------------------------------------------------------------------------------------------------------------------------- EXERCISE ON LESSON TWO 1. What are the three main types of variables used in Java and what are they used to store? 2. What type of variable would you use to store your name? 3. What type of variable would you use to store the square root of 2? 4. What type of variable would you use to store your age? 5. Write a single line of code that will create a double precision variable called p and store 1.921 X 10-16 in it. 6. Write a single line of code that will create an integer variable called i and store 407 in it. 7. Write a single line of code that will create a String variable called my_name and store your name in it. 8. Write a line of code that will declare the variable count to be of type int. Don’t initialize. 9. Write a line of code that initializes the double precision variable bankBalance to 136.05. Assume this variable has already been declared. 10. Which of the following are legal variable names? scooter13 139_scooter homer-5 ;mary public doubled double ab c 11. Which of the following is the most acceptable way of naming a variable. Multiple answers are possible. a. GroovyDude b. GROOVYDUDE c. groovyDude d. Groovydude e. groovy_dude f. groovydude 12. Comment on the legality of the following two lines of code. double dist = 1003; int alt = 1493.86; [/color] |
Programming / Re: I Need A Helping Hand Here Please by okunade(m): 4:11pm On Mar 11, 2009 |
it is not a problem. i will introduce you to JAVA check the thread of LEARN JAVA HERE EASILY |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 3:47pm On Mar 11, 2009 |
LESSON ONE, Program Skeleton: Enter the following program skeleton, compile (prepare it to run), and then run (execute). public class Tester { public static void main(String args[]) { } } At this point don’t worry about what any of this means. It’s just something we must do every time. Soon we will learn the meaning of all of this. For now it’s just the skeleton that we need for a program. Adding some meaningful code: Now, let’s add some meaningful code inside the main method. (Notice this word, METHOD. We will constantly refer to methods throughout this TUTORIAL.) We will also add a remark. public class Tester //We could put any name here besides Tester { public static void main(String args[]) { System.out.println("Hello world" } } Remarks: Notice the rem (remark or in Fortran or C++ call comment) above that starts with //. You can put remarks anywhere in the program without it affecting program operation. Remarks are also called comments or notes. Printing: System.out.println("Hello world" ); This is how we get the computer to printout something. Notice the trailing semicolon. Most lines of code are required to end in a semicolon. Now try putting in some other things in the println parenthesis above. Each time recompile and run the program: 1. "Peter Piper picked a peck of pickled peppers." 2. "I like computer science." 3. 25/5 4. 4 / 7.0445902 5. 13 * 159.56 Two printlns for the price of one: Next, modify your program so that the main method looks as follows: public static void main(String args[]) { System.out.println(“Hello world”); System.out.println(“Hello again”); } Run this and note that it prints : Hello world Hello again Printing “Sideways”: Now remove the ln from the first println as follows: public static void main(String args[]) { System.out.print(“Hello world”); System.out.println(“Hello again”); } Run this and note that it prints: Hello worldHello again Here are the rules concerning println and print: • System.out.println( ) completes printing on the current line and pulls the print position down to the next line where any subsequent printing continues. • System.out.print( ) prints on the current line and stops there. Any subsequent printing continues from that point. An in-depth look at rems: Let’s take a further look at rems. Consider the following program (class) in which we wish to document ourselves as the programmer, the date of creation, and our school: public class Tester { //Programmer: Okunade //Date created: Mar 11, 2009 //School: OAU public static void main(String args[]) { System.out.println("Hello again" } } Block rems: It can get a little tedious putting the double slash rem-indicator in front of each line, especially if we have quite a few remark lines. In this case we can “block rem” all the comment lines as follows: public class Tester { /*Programmer: Okunade Date created: Mar 11, 2009 School: OAU public static void main(String args[]) { System.out.println("Hello again" } } Notice we use /* to indicate the start of the block and */ for the end. Everything between these two symbols is considered to be a remark and will be ignored by the computer when compiling and running. HERE IS ASSIGNMENT FOR YOU, Project… From Me To You Create a new project called FromMeToYou having a Tester class with the following content. Also include remarks above public class Tester that identifies you as the author along with the date of creation of this program: //Author: Okunade //Date created: Mar 22, 2009 public class Tester { public static void main(String args[]) { ------------------------------ } } Supply code in the place of --------------- that will produce the following printout: From: Okunade Address: OAU Computer, Bldg Ife Date: Mar 11, 2009 To: Bill Gates Message: Help! I need to be a Programmer! |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 1:59pm On Mar 11, 2009 |
azpunpin: pls visit www.java.sun.com for your jdk update |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 1:37pm On Mar 10, 2009 |
Thanks House. I've many issues to clear, but firstly Im very sorry that I didn't post since thursday, 1. About the IDE, I said IDE is free and can be downloaded free of charge. But in case of those who are asking for the licence I ask them to get it from the site or mail me.Clear(ade2kay) 2. About using textpad, there is no compulsion in using IDE You can use textpad but using any IDE will make your program look nicely, and you can run your program by just clicking a button.(Note any IDE can be used, just go to google and write "free java IDE" 3. Thanks azpumpin it was a mistake the line is ("Welcome to Java World!, \nThis is my first program" 4. { is used to open the program and also is also used to open any method you use in your program. the method used is main method so for main method you will need to open { for it 5. As for now Declaring any class or method public should be accepted until Chapter that described (Method--private,public,protected) 6. importing a scanner class should be done when writting from a keyboard, to a file etc this is how it should be done import java.util.*; import java.io.*; Scanner class is in the java utility package so when you need it just iport the whole package by ( import java.util.* 7. summing up two integers import java.util.*; import java.io.*; public class Addition { public static void main(String args[]) // can also be written as String []args, you will understand better when doing Array. { Scanner kb = new Scanner(System.in); // make Scanner object kb int firstValue, secondValue; // Declaring variable int sum; System.out.print("Enter the first value : " firstValue = kb.nextInt; System.out.print("Enter the second value : " secondValue = kb.nextInt; sum = firstValue + secondValue; System.out.println("The result is "+sum); } } [/color][color=#990000][/color][color=#990000][/color][color=#990000][/color][color=#990000][color=#990000][/color]That is it, one house, |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 4:34pm On Mar 05, 2009 |
LESSON 3 Myfirst Java Program, Open the text editor in your IDE. Write the following code, ======================================================== public class myFirstProg { public static void main(String args[]) { system.out.println("Welcome to Java World!, \nThis is my first program); } } ========================================================= We are using JCreator software(if u dont have one already, download it at www.jcreator.com) to run this program, save your text as myFirstProg.java press F5, wait for response, that's all. ---------------------------------------------------- Explanation of the program: line 1: public class myFirstProg { this is class definition. the first thing in Java program is to define your class and the name of your class must be the same as the name of your program(Here the class name is myFirstProg which must be the same as the name of your text file) Also our class is define as public(you will know this later on) A right curly { bracket is used to open the program, To be Continued, |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 4:10pm On Mar 05, 2009 |
jacob05: The IDE can be downloaded free of charge, but that is trial version. If you need the Licence key, you will pay for it. It cost only $51.50. so if you need it just send mail to guessy2k2@yahoo.com OK The Trial Version is for just 30 days only thanks, |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 11:48am On Mar 04, 2009 |
LESSON TWO We are going to be looking at Java Applications, Applets, and Database Connectivity. Before we continue, we are going to talk about various IDE(Integrated Development Environment) to write, compile, and run our java program. The best IDE I will recommend is JCreator which can be downloaded from www.jcreator.com. The Advantage of this software is to enable us to feel the fonts, and colours the text gives us. After you have installed the JCreator software. The we can Continue our program, |
Programming / Re: Learn Java Programming Here Easily by okunade(m): 11:33am On Mar 04, 2009 |
geek4ever: Both Applications and Applets. Not only Java but also C++,Python,C, and Fortran2003 |
(1) (2) (of 2 pages)
(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. 91 |