Uploaded by Arnob Hasan

Lab Task 1 and 2

advertisement
Lab Task – 1 and 2
Md. Mehedi Hasan Nayon
ID - 191-15-12561
Section - M
1. Print “Hello Class” in JAVA.
2. Print Multiple Lines.
3. Add two integers and print the result.
1
public class HelloClass {
public static void main(String[]args)
{
System.out.println("Hello Class");
}
}
2
public class Multiple {
public static void main(String[]args)
{
System.out.println("Hello ma'am how are you?");
System.out.println("I hope, you are well by the grace of almighty Allah.");
System.out.println("You are the most cutest ma'am I have met in my life.");
}
}
3
public class Addition {
public static void main(String[]args)
{
int x=23,y=32;
System.out.println("ADD = "+(x+y));
}
}
Home Work
1. Print Your Information (Name, ID, Address, department, favorite
game etc).
2. Initialize a variable with your name and then print it.
3. Find the area of a Circle
1
public class Information {
public static void main(String[]args)
{
String Name="Raibul Hasan",ID="221-154684",Address="Naogaon",Dept="CSE",Fgame="Batminton";
System.out.printf("Name =%s\nID = %s\nAddress = %s\n",Name,ID,Address);
System.out.printf("Dept =%s\nFgame = %s\n",Dept,Fgame);
}
}
2
public class Information {
public static void main(String[]args)
{
String Name="Raibul Hasan",ID="221-154684",Address="Naogaon",Dept="CSE",Fgame="Batminton";
System.out.printf("Name =%s\nID = %s\nAddress = %s\n",Name,ID,Address);
System.out.printf("Dept =%s\nFgame = %s\n",Dept,Fgame);
}
}
3
import java.util.Scanner;
public class Area_of_Circle {
public static void main(String[] args) {
Scanner redious=new Scanner(System.in);
double p=3.1416;
double r = redious.nextInt();
System.out.println("Circle Area= "+(p*r*r));
}
}
Lab task 2
Solution
import java.util.Scanner;
public class Lab_Task2 {
public static void main(String[] args) {
Scanner number =new Scanner(System.in);
double marks=number.nextDouble();
if( marks>=80 )
System.out.println("Gread Point = 4.00");
else if(marks<80 && marks>=75)
System.out.println("Gread Point = 3.75");
else if(marks<75 && marks>=70)
System.out.println("Gread Point = 3.50");
else if(marks<70 && marks>=65)
System.out.println("Gread Point = 3.25");
else if(marks<65 && marks>=60)
System.out.println("Gread Point = 3.00");
else if(marks<60 && marks>=55)
System.out.println("Gread Point = 2.75");
else if(marks<55 && marks>=50)
System.out.println("Gread Point = 2.50");
else if(marks<50 && marks>=45)
System.out.println("Gread Point = 2.25");
else if(marks<45 && marks>=40)
System.out.println("Gread Point = 2.00");
else if(marks<40)
System.out.println("Gread Point = 0.00");
}
}
Download