IS5103 Week 1 Lab’s

LESSON-1 labs 

1

import java.io.*; 

import java.util.*; 

public class MyClass{ 

 public static void main(String[]args){ 

 Scanner in = new Scanner(System.in); 

 int a, b, sum; 

 a = in.nextInt(); 

 b = in.nextInt(); 

 sum = a + b; 

 System.out.println(“Sum = ” + sum); 

 } 

2. 

public class Main{ 

 static void printDetails(String name, int age){  System.out.println(“The age of “+name+” is “+age+”.”);  } 

 public static void main(String[] args){ 

 printDetails(“Henry”, 42); 

 } 

3. 

class Employee{ 

 String name; 

 String designation; 

 Employee(String name, String designation){

 this.name = name; 

 this.designation = designation; 

 } 

public class Main{ 

 public static void main(String[] args){ 

 Employee emp = new Employee(“Andrew Lewis”, “Technical Lead”);  System.out.println(“Employee name: ” + emp.name);  System.out.println(“Designation: ” + emp.designation);  } 

4. public class Main{ 

 public static void main(String[] args){ 

 Character a = Character.valueOf(‘A’); 

 Character b = Character.valueOf(‘B’); 

 System.out.println(“Resultant sum = ” + (a + b)); 

 } 

LESSON-2 labs 

public class Opr{ 

 public static void main(String[] args){  int a = 7; 

 int b = 4; 

 int c = a / b; 

 int d = a % b;

 //Write your code here… 

 System.out.println(“Quotient: ” + c);  System.out.print(“Remainder: ” + d);  } 

2. import java.io.*; 

import java.util.Scanner; 

public class Operator{ 

public static void main(String args[]){ 

 int a, b, c; 

 Scanner in = new Scanner(System.in); 

 a = in.nextInt(); 

 b = in.nextInt(); 

 c = in.nextInt(); 

 if((a > b) & (a > c)){ 

 System.out.println(“a is greater than both b and c.”);  } 

 else{ 

 System.out.println(“a is either less than b or c or both.”);  } 

3. import java.io.*; 

import java.util.Scanner;

public class Operator{ 

public static void main(String args[]){ 

 int a, b, c; 

 Scanner in = new Scanner(System.in); 

 a = in.nextInt(); 

 b = in.nextInt(); 

 c = in.nextInt(); 

 if((a > b) | (a > c)){ 

 System.out.println(“a is greater than either b or c.”);  } 

 else{ 

 System.out.println(“a is less than both b and c.”);  } 

4. import java.io.*; 

import java.util.*; 

public class Oper{ 

public static void main(String[] args){ 

 Scanner in = new Scanner(System.in); 

 float marks; 

 marks = in.nextFloat(); 

 String result = marks > 60 ? “Pass” : “Fail”; 

 System.out.print(result); 

}

}

Other Links:

Statistics Quiz

Networking Quiz

See other websites for quiz:

Check on QUIZLET

Check on CHEGG

Leave a Reply

Your email address will not be published. Required fields are marked *