SDA - Lab 6 - 2k22
SDA - Lab 6 - 2k22
Laboratory # 06
UET TAXILA
Engr. Sidra Shafi
JDK INSTALLATION:
For compiling and running java programs we need to install Java Development Kit (JDK).
The JDK is a development environment for building applications and components using the Java
programming language.
The JDK includes tools for developing and testing programs written in the Java programming
language and running on the Java platform.
INSTALLATION STEPS:
1. Double click the jdk exe. A window will open. Click NEXT to move ahead.
2. Select the directory where you want to install this software.
3. Then click next.
4. Click Close after successfully installed message appears.
5. Now you can create, compile, and run java programs.
iii. Select Path under System variables. Double click this path.
This will print out the version of the java compiler if the Path variable is set correctly or “javac is not
recognized as an internal or external command…” otherwise
https://www.eclipse.org/downloads/
Select the Java Version and Installation folder by clicking folder on right side.
dependencies.
Click Finish.
It will ask to Open Perspective. Click Open Perspective option in Next window.
Create new Class and type the above code. Click on run icon. Eclipse will show output on console.
Task 1: Marks: 4
Run the following codes in Eclipse and observer the outputs.
Program # 1
public class Program1 {
//your program begins with a call to main()
public static void main(String[] args) {
System.out.println("Welcome to Java World!"); //println() displays the string which
is passed to it.
} }
Program # 2
class Program2 {
public static void main(String[] args) {
int a,b,c; //this statement declares three variables a, b and c.
a=2;
b=3;
c=a+b;
System.out.println("Sum of two numbers = "+c); } }
Task 2: Marks: 6
Write a method that converts hours into seconds.
Examples:
howManySeconds(2) ➞ 7200
howManySeconds(10) ➞ 36000
howManySeconds(24) ➞ 86400
*****************