Professional Documents
Culture Documents
Lab Practical
Lab Practical
Lab Practical
Objective: Get familiar with Java Environment and Integrated Development Environment
(IDE).
Description: Installation of Java Development Kit (JDK) and installing Netbeans, and write
“Hello World” program.
Code:
package imran.bhambhro;
System.out.println("Hello World");
}}
Practical No: 2
Objective: Getting familiar with Java environment and writing simple programs.
package imran.bhambhro;
import java.util.Scanner;
int a, b;
Scanner i;
i = new Scanner(System.in);
a = i.nextInt();
b = i.nextInt();
String s=(b==a)?"A and B are equal (by Ternary Op:)":"A & B are not equal (by Ternary Op:)";
System.out.println(s);
a++;
b++;
b--;
a--;}}
Screenshot
Practical No: 3
Objective: Getting familiar with conditional structures and how we use conditional structure in
different scenario.
Description: Task 1: Take input from user, and generate Electricity Bill.
100 units X 5, 200 units X 6, 300 units X 7, 400 units X 8, 500+ units X 10.
Task 3: Getting familiar with the control structure and write a program, take input
Task 4: Getting familiar with nested loops, and conditional structures working
palindrome triangle.
Task 5: Write a program that can take input from user and generate stars as
square.
Task 6: Write a program that can take input from user and generate Fibonacci
series.
package imran.bhambhro.pkg3;
import java.util.Scanner;
Scanner s;
unit = s.nextInt();
System.out.println(total);}}
Screenshot
Task 2: Marksheet
package imran.bhambhro.pkg2;
import java.util.Scanner;
float perc,sum,total=500;
Scanner s;
Scanner t;
t = new Scanner(System.in);
s = new Scanner(System.in);
System.out.println();
s = new Scanner(System.in);
eng = s.nextInt();
s = new Scanner(System.in);
bio = s.nextInt();
math = s.nextInt();
s = new Scanner(System.in);
chem = s.nextInt();
s = new Scanner(System.in);
phy = s.nextInt();
System.out.println();
System.out.println();
sum = eng+math+bio+phy+chem;
perc=sum*100/total;
System.out.println("Percentage: "+perc);}}
Screenshot
Task 3: Factorial Number
Code:
package factorial;
import java.util.Scanner;
System.out.println(fac());
long b=1;
long a = sc.nextInt();
b*=i;
return b;
}}
Screenshot
Task 4: Palindrome Triangle
Netbeans code
package imran.bhambhro.pkg4;
import java.util.Scanner;
int n = s.nextInt();
System.out.print(" ");
System.out.print(j);
System.out.print(j);
System.out.println();}}}
Screenshot
Code:
package imranbhambhro5;
import java.util.Scanner;
long n = sc.nextInt();
long a=0,b=1,total;
{total = a+b;
System.out.print(total + " ");
a=b;
b=total;}
System.out.println();}}
Screenshot