java_fundamentals
java_fundamentals copied to clipboard
I need java source code about how to use: for, do-while, and while
Would be nice have challenges about loops in java or code with some problem solved.
For-Loop Example:
for (int i = 0; i < 10; i++) {
System.out.println(i);
}
Do-While-Loop Example
do {
// Your code
} while (condition);
While-Loop Example
while(condition) {
// Your code
}
Hope i could help you. Happy Hacktoberfest.
@V1ncNet Thanks for your contributions, in the slides we have the documentation about hout to use the loops, but we need more examples and more ploblems to solve or solven in code.
Hi, I would like to do this!
Hi, When I started out learning a programming language for the first time I remember the following problems being vital in understanding and applying loops effectively. As a learning exercise the student should implement all the questions using all types of loops available in the language.
- Write a main method that will read in integers until a negative value is entered, and displays the sum of all of the non-negative value that had been entered.
- Print the patterns (n = 5 in this example, make n as user input)
*
**
***
****
*****
- Print a pyramid pattern of *'s. Number of rows in the pyramid could be a user input.
- Print pascals triangle given n (user input)
- Find the reverse of a given number n
- Print the following pattern
*****
****
***
**
*
Let me know if these questions work. If yes, I'll code the solutions and post them here.
Cheers!
@tombiju We are waiting for your help! @AdityaAS thank you, good problems. I like to update each folder, with the exercises. so we need more help. I'll publish more issues.
@xaca Could you tell me how I should go about organizing the solutions. I was thinking for each problem I'll defined a method in the files "ForLoop.java" and "WhileLoop.java" and call them from the main function. Does that work?
@AdityaAS Yes, this aproach is good. Each class could have a main method, or share a same main. Is your call.
@xaca I would like to add a Program related to oops as well. Do tell me if you want that. The question is of multiplication, addition and subtraction of polynomials using oops.
@ribhav-pahuja Course this program is important, please contribute.
@xaca Will surely add what I fell like is important for this course. Thanks