Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Main {
- public static void main(String[] args) {
- System.out.println("Hello World! \n It's been nice knowing you. \n Goodbye World ");
- }
- }
- class Main {
- public static void main(String[] args) {
- System.out.println("==================================");
- System.out.println("= Student Information =");
- System.out.println("==================================");
- System.out.println("= Name : ARDP Ranasignhe =");
- System.out.println("= Reg No : DIS\t08\tM4\t1234 =");
- System.out.println("= Address : Malabe =");
- System.out.println("==================================");
- }
- }
- class Main {
- public static void main(String[] args) {
- int age=20;
- if (age > 18){
- System.out.print("Adult");
- }
- else{
- System.out.print("Child");
- }
- }
- }
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner= new Scanner(System.in);
- System.out.print("Value of the day : ");
- int val=scanner.nextInt();
- switch (val) {
- case 1:
- System.out.println("Day of the week : Monday");
- break;
- case 2:
- System.out.println("Day of the week : Tuesday");
- break;
- case 3:
- System.out.println("Day of the week : Wednesday");
- break;
- case 4:
- System.out.println("Day of the week : Thursday");
- break;
- case 5:
- System.out.println("Day of the week : Friday");
- break;
- case 6:
- System.out.println("Day of the week : Saturday");
- break;
- case 7:
- System.out.println("Day of the week : Sunday");
- break;
- }
- System.out.print("Good Bye!");
- }
- }
- class Main {
- public static void main(String[] args) {
- int m=1,o=1;
- while (o<=5){
- m=0;
- while (m<=5)
- {
- System.out.print("*");
- m++;
- }
- System.out.println();
- o++;
- }
- for (int i=0; i<5; i++) {
- for (int j=5-i; j>1; j--){
- System.out.print(" ");
- }
- for (int j=0; j<=i; j++ ){
- System.out.print("* ");
- }
- System.out.println();
- }
- }
- }
- class Main {
- public static void main(String[] args) {
- int k = 10;
- for(int i = 0; i < 5; i++) {
- for(int j = 0; j < 5; j++) {
- System.out.print("* ");
- }
- for(int m = 1; m < k; m++) {
- System.out.print(" ");
- }
- k--;
- for(int n = 0; n <= i; n++) {
- System.out.print("* ");
- }
- System.out.println();
- }
- }
- }
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- int num1,num2;
- Scanner scanner=new Scanner (System.in);
- System.out.println("Enter two numbers");
- num1=scanner.nextInt();
- num2=scanner.nextInt();
- System.out.println("The Avergae of the two number is:- "+(num1+num2)/2);
- }
- }
- lab 2
- class Main {
- public static void main(String[] args) {
- int miles = 26,yards = 385;
- double kilometers = 0;
- // Write the expression to convert the given values to kilometers
- miles=miles+(1760*yards);
- kilometers=(miles*1.609);
- System.out.println("Number of kilometers are " + kilometers);
- }
- }
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- String name,id,district;
- Scanner scanner=new Scanner(System.in);
- System.out.print("Enter the Student's First Name :- ");
- name=scanner.nextLine();
- System.out.print("Enter the Student's ID :- ");
- id=scanner.nextLine();
- System.out.print("Enter the Student's District :- ");
- district=scanner.nextLine();
- System.out.println("DitNo : "+name);
- System.out.println("Name: "+id);
- System.out.println("District : "+district);
- }
- }
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- int length, width, height;
- int volume = 0;
- Scanner scanner=new Scanner(System.in);
- //Take user inputs using Scanner class
- System.out.println("Enter the length of the cube:-");
- length=scanner.nextInt();
- System.out.println("Enter the width of the cube:-");
- width=scanner.nextInt();
- System.out.println("Enter the height of the cube:-");
- height=scanner.nextInt();
- //Calculate the volume of cube
- volume=length*width*height;
- System.out.println("Volume of the cube : "+volume);
- }
- }
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- class Main {
- public static void main(String[] args) {
- int length, width, height;
- int volume = 0;
- String l,w,h;
- //Take user inputs using InputStreamReader class or BufferedReader class
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Enter the length of the cube:-");
- l = reader.readLine();
- length=Integer.parseInt(l);
- System.out.println("Enter the width of the cube:-");
- w = reader.readLine();
- width=Integer.parseInt(w);
- System.out.println("Enter the height of the cube:-");
- h = reader.readLine();
- height=Integer.parseInt(h);
- //Calculate the volume of cube
- volume=length*width*height;
- //Calculate the volume of cube
- System.out.println("Volume of the cube : "+volume);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement