Skip to content

Learning java with project based learning system. (from beginner)

Notifications You must be signed in to change notification settings

Burakegekocabay/Learning-Java

Repository files navigation

Learning-Java

Learning java with project based learning system. (from beginner)
Try to solve question in Readme.MD file according to Algorithm.
Then go to Project and check your answer from source code.

Algorithm

-Take 2-digit input with Scanner.
-Separate into digits
-Print the digits.

Output

Enter a 2-digit number : 75(input)
Digits are 7 and 5.

Problem

Write a program that converts a Fahrenheit degree to Celsius

Algorithm

-Take input for Fahrenheit
-Use the mathematics expression to convert
-Print the Celsius

Output

Enter the Fahrenheit: 56(input)
56 Fahrenheit equals 13.333 Celsius

Problem

The program randomly generates two single-digit integers number1 and number2 and displays a question such as “What is 7 + 9?” to the student. After the student types the answer, the program displays a message to indicate whether the answer is true or false

Output

What is 5 + 1? (random)
6(input)
Answer is True.
///////
What is 6+1? (random)
9(input)
Answer is False.

Problem

This program first prompts the user to enter a year as an int value and checks if it is a leap year.

Algorithm

A year is a leap year if it is divisible by 4 but not by 100, or it is divisible by 400.

Output

Enter a year: 2024(input)
2024 is a leap year.
///////
Enter a year: 2000(input)
2000 is not a leap year.

Problem

Type 100 times "I'm learning java" with for loop.

Output

I'm learning java
I'm learning java
I'm learning java
.
.
I'm learning java

Problem

Write a program that randomly generates an integer between 0 and 100, inclusive. The program prompts the user to enter a number continuously until the number matches the randomly generated number. For each user input, the program tells the user whether the input is too low or too high, so the user can choose the next input intelligently.

Output

I hold a number guess it.
64(input)
go up
80(input)
go down
75(input)
You found number.

Problem

A string is a palindrome if it reads the same forward and backward. The words “mom,” “dad,” and “noon,” for instance, are all palindromes.

Algorithm

Solution is to check whether the first character in the string is the same as the last character. If so, check whether the second character is the same as the second-to-last character. This process continues until a mismatch is found or all the characters in the string are checked

Output

Enter a word: radar(input)
radar is a palindrome word.
///////
Enter a word: test(input)
test is not a palindrome word.

Problem

Write a program that displays the first 50 prime numbers in five lines, each of which contains 10 numbers.

Algorithm

An integer greater than 1 is prime if its only positive divisor is 1 or itself. For example, 2, 3, 5, and 7 are prime numbers, but 4, 6, 8, and 9 are not
If a number is not divisible by any number preceding it (except 1) without remainder, it is a prime number. For example, 5 is not equally divisible by 4, 3, or 2, so 5 is a prime number

Output

2 3 5 7 11 13 17 19 23 29
31 37 41 43 47 53 59 61 67 71
73 79 83 89 97 101 103 107 109 113
127 131 137 139 149 151 157 163 167 173
179 181 191 193 197 199 211 223 227 229

Problem

Read 50 numbers, store it in an integer array. compute their average, and find out how many numbers are above the average.

Output

Number 1: 24(input)
Number 2: 56(input)
.
.
Number 50: 72(input)

Average: 62.2
15 number are above the average.

Problem

Class contains 50 students
Exam Contains 100 questions
Each questions contains 4 choices (as ‘A’, ‘B’,’C’ and ‘D’) and empty answer (if not filled)
(all of them have same probability)
Each question equal 1 point and 4 incorrect answer delete 1 point from total grade

Algorithm

Randomly generate an exam result
Ramdomly generate a key
Evaluate the exam and list the results on the screen.

Output

Student 1 : 70 Correct, 28 Incorect, 2 Empty answers=63 points
Student 2 : 71 Correct, 29 Incorect, 0 Empty answers=63,75 points
Student 3 : 62 Correct, 3 Incorect, 35 Empty answers=61,25 points

Problem

Write a function which takes a positive integer and returns all its positive divisors.

Algorithm

Create a ArrayList
While x < number
if number can divisible by x
add ArrayList

Output

Enter a number : 20(input)
divisors(20) = [1, 2, 4, 5, 10, 20]

Problem

write a Java method which reverse this List : [1,2,3,4,5]

Algorithm

Take first element
put first element to last index
continue until list done.

Output

Before : [1,2,3,4,5]
After : [5,4,3,2,1]

Problem

Write a Java program, which reads a String from the Keyboard and display the characters used in this String in the screen.

Output

Enter a string: HELLLOOO(input)
[E,H,L,O] (no order)

Problem

Write a Java program, which reads a String from the Keyboard and display the characters and their number of usage in the screen.

Output

Enter a string : HELLO WORLD(input)
L=3 ,E=1, H=1, O=2 ,R=1 ,D=1 , =1 , W=1 (no specific order)

Problem

Write a function which takes a string and checks if all of the parentheses (if any) in it are balanced.

Algorithm

if char is '(' add to stack
if char is ') remove from stack
so if stack empty it means balanced

Output

"he()l()lo" = true
"(yes)(i)am(ba(lan)ced)" = true
"((something)" = false
"no parenthesis" = true
"somet(hing" = false

Problem

Write a function which takes two circles and returns true if they intersect with each other

Algorithm

Create a Point class with has (double x , y;) variables
Create a Circle class with has (Point origin;) and (double radius;) variable
(means circle1.origin = point1 value)

If square root ( (x2-x1)^2 + (y2-y1)^2 ) < radius1+radius2 : intersect is true

Output.txt

Enter: point1.x =3(input) Enter point1.y =4(input) Circle1.radius=2(input) Enter: point2.x =7 Enter point2.y =5(input) Circle2.radius= 8 (input) is Circle Intersect : True.

Problem

Create a output.txt file with usage of Printwriter and FileOutputStream
Write a sentences to txt file 3 times with for loop
(Don't forget try-catch block)

Output.txt

1-Hello World.
2-Hello World.
3-Hello World.

Problem

Open output.txt file with BufferedReader , read lines and print them to console
(output.txt file is a example file which created in Project 17)

Output

1-Hello World.
2-Hello World.
3-Hello World.

Problem

Read the folloving values from a input.txt file (create it manually) and get sum of these values

input.txt

12,45,145,90,65,11
3453,567,22,104
1239,45
123,545,678

Output

The sum of 1st line: ...
The sum of 2nd line: ...
The sum of 3rd line: ...
Thu sum of 4th line: ...

Problem

Write a simple Java program that lists some essential properties of a file, including its length, whether it is readable, writable, executable, and when it was last modified. This program uses Java's File class to handle file operations.

Problem

Write a Java method that deletes a folder and all of its contents, including subfolders and files. This program uses Java's File class to handle file operations.

Introduction to JAVAFX (GUI)

Download JAVAFX and make configuration to your VSCODE/INTELLIJ/etc.
Open a new JAVAFX project from your code editor.
Make sure your Main class extends from Application
Do not forget import javafx tools.

Main class path

ProjectName -> src -> main -> java -> com.example(package) -> main class

JAVAFX-1 : Beginning

Problem

Download and Run the code (Click)

Problem

Make a button named: "Say : Hello GUI"
When pressed the button print "HELLO GUI" to console.

Problem

Make a login form require username and password and sign button
When pressed to button show a text : Log in succesfull.

Problem

Make a basic calculator which have 4 button (+,-,*,/)
When pressed a button Calculate and show result in textField

Releases

No releases published

Packages

 
 
 

Languages