Greetings to All
Hy guys, I wish you all will be great by the blessings and mercy of Almighty Allah. So today I am going to participate in the learning Challenge of the Steemit Season 22 Week 1.The first Challenge that I am going to start this week is about the introduction to java that course is designed by @kouba1. So let's start by exploring the home tasks and their answers.
Write a detailed explanation of the differences between JDK, JRE, and JVM by including their roles, functionalities, and interdependence. Add graphic illustrations which cover this points : |
---|
Introduction to java |
---|
Java is a popular programming language that operates through several essential components like JDK , JRE and JVM it helps us to understand How Java work as a programming platform so today we will dive deeper into these concepts.
|
---|
JDK is a development toolkit that is used to write compile and debug our Java codes and applications it is considered as the primary tool for Java developers. Its core functionality contains the Java compiler to convert source code into byte code include libraries and development tools for Java application creation and also provide the JRE.
Functionalities: |
---|
Key Components: |
---|
Java Compiler
Debugging Tools
Documentation Generator (javadoc)
Java Runtime Environment (JRE)
Illustration:
+-------------------+
| Java Programs |
+-------------------+
|
+-------------------+
| JDK |
|-------------------|
| Compiler, JRE, |
| Libraries |
+-------------------+
Java runtime environment or in simple jre needed to execute Java applications it is basically designed for the end users who wants to run their Java programs.
|
---|
Functionalities: |
---|
it Includes the JVM to execute bytecode.
Also Provide standard libraries and class files.
Does not include tools for writing or compiling code.
Key Components: |
---|
Java Virtual Machine (JVM)
Core Libraries
Supporting Files
Illustration:
+-------------------+
| Bytecode |
+-------------------+
|
+-------------------+
| JRE |
|-------------------|
| JVM, Libraries |
| Supporting Files |
+-------------------+
The JVM is the Indian diet helps to run the Java byte code it acts as a assembly layer between the byte code and operating system to proceed.
|
---|
Functionalities: |
---|
Key Features: |
---|
Illustration:
+-------------------+
| Machine Code |
+-------------------+
|
+-------------------+
| JVM |
|-------------------|
| Bytecode, Memory, |
| Thread Mgmt |
+-------------------+
|
---|
Comprehensive Diagram:
+---------------------+
| JDK |
|---------------------|
| Compiler, Debugger |
| Javadoc, JRE |
+---------------------+
|
+---------------------+
| JRE |
|---------------------|
| JVM, Libraries |
| Supporting Files |
+---------------------+
|
+---------------------+
| JVM |
|---------------------|
| Bytecode Execution |
| Garbage Collection |
+---------------------+
By understanding these components developers will be able to use and define that how Java enables an efficient development and execution across the platform.
Install and Set Up Your Java Development Environment and provide step-by-step screenshots of the installation process, Eclipse configuration. |
---|
These are the steps that I have followed to install and configure my javas Development environment here we'll see the details by using screenshots and elaborating the process.
Step 1: Download the JDK |
---|
Firstly I go to Oracle JDKWebsite.
Secondly I select the appropriate version of JDK for my operating system that was windows installer x64 and download it. The Screenshots you can see below.
Step 2: Install the JDK |
---|
C:\Program Files\Java\jdk-
).Step 3: Set Environment Variables |
---|
And add new system variable that was named as Java home and its value was the path to the installation directory then I click on ok to proceed.
Step 4: Verify Java Installation |
---|
To verify the installation I opened my command prompt and run the command of java--version and then javac--version to check out the variance installed in my PC.
Step 5: Download and Install Eclipse IDE
Download the Eclipse IDE for Java Developers.
Then I proceed to launch the installer after it was completely installed I set it up.
Step 6: Create and Run a Java Project |
---|
File
→ New
→ Java Project
.Then I add the new class and and the compiler new class was added as shown in screenshots below.
Then write a simple "Hello, World!" program in a new class.
Run the program and verify the output in the console.
By completing these steps I have a fully functional Java development environment that was ready for writing and done in Java programs so lets proceed with the next tasks.
By completing these steps, you will have a fully functional Java development environment ready for writing and running Java programs.
Write a program that calculates and displays the sum of the first 100 integers. Define the main method in a class named Sum to handle the entire calculation.
|
---|
Save this program in a file named Sum.java, compile it, and execute it.Create a new program named Sum2.java, where the calculation of the sum of the first 100 integers is performed in a separate function called calculateSum. This function should then be called from the main method. |
---|
In this task we will write two paragraphs to calculate the sum of 100 integers using the Java.
Program with Calculation in the |
---|
Explanation:
In this program we will use for
loop to calculate the sum of integers from 1 to 100. the result will be stored in the variable sum and after the loop completes it printed it on the console.
Firstly I save the code in Sum.java file and run the code by clicking on the run button
This will show the following output
Output:
The sum of the first 100 integers is: 5050
Program with Calculation in a Separate Function
calculateSum()
method. The main()
method calls this function and prints the result.Firstly I write the code in Sum2.Java
Output:
The sum of the first 100 integers is: 5050
So we have calculated the sums by using groups and functions in Java.
public static void main(String[] args) {
System.out.print("Tax: ");
System.out.println(calculateTax(57000));
}
}
Here is the complete, translated, and debugged version of the program Tax.java
to calculate tax based on the given income brackets:
Explanation of the Tax Calculation: |
---|
Bracket T1 (≤ 20,000):
20000 * 0.05 = 1000
Bracket T2 (20,001 to 40,000):
(40000 – 20000) * 0.10 = 2000
Bracket T3 (40,001 to 60,000):
(57000 – 40000) * 0.15 = 2550
Total Tax:
1000 + 2000 + 2550 = 5550
calculateTax
Method checks the income against different brackets and applies the appropriate tax rate for each segment of the total tax will be calculated by summing up the tax for each bracketThis will output the calculated tax for an income of 57,000
as:
Tax: 5550.0
Tax: 5550.0
Screenshots you can see below.
Using the same program structure as in the previous exercise, write a program named Conversion.java that takes a character c as a parameter and:If the character is lowercase, convert it to uppercase and display the following message:"The uppercase equivalent of c is ..."If the character is uppercase, convert it tolowercase and display the following message:"The lowercase equivalent of c is ..."If the character is not a letter, display the following message:"c is not a letter.". |
---|
Now we would talk that how programs works it actually takes string of Chracter as input and processes each character It convert lower case letters to upper case and upper case letters to lowercase and also identify a non letter Chracters.
The program uses a scanner object to capture user input in the form of corrector or also input a string the program can handle multiple characters making it flexible for various scenarios scenarios.
To process each character a loop is used this loop iterates through the string and extract the corrector at a time to proceed.
The program will display the result of each character analysis and convergent immediately and provide the real time feedback for the input string.
Hello123
.H
→ Convert to lowercase → h
e
→ Convert to uppercase → E
l
→ Convert to uppercase → L
l
→ Convert to uppercase → L
o
→ Convert to uppercase → O
1
→ Not a letter2
→ Not a letter3
→ Not a letterSo in this question we will explore about array operations here the program I have designed that will ask user to input the array size and elements it displays a menu with options to perform different operations based on the user choice. It will find the display largest element compute the sum of the elements and sort the array and displays it if user select exit the program will terminate.
The code you can see in the screen shot the program Itrates through the array To complete each element identify and sorting secondly it will perform the task of calculating the sum of elements where loop is used to add elements of the array to a running total the final sum will be displayed on the screen.
Finally, it will sort the array using bubble sort algorithm and arrange the array in ascending order user can select what operation he wants to perform.
So that was all from my side about the topic and I hope that you all will like to read the post and support the content
I would like to invite
to participate in the contest
Regards @mateenfatima |
---|