MST LAB Worksheet
MST LAB Worksheet
Note:
1. Attempt the questions that are assigned to you and you have executed.
3. UIDs with Even numbers attempt the SET-A and with Odd numbers attempt the SET-B.
4. Make pdf of your programs with outputs and upload on Blackboard within time constraints.
SET-A
Experiments:
Q1. WAP if we enter case 1 then it will execute greater no among 2 no’s. If case 2 then even or odd program
otherwise it will show message Plz enter case no either 1 or 2.
Q2. WAP of default constructor in Java.
SET-B
Experiments:
Q1. WAP if we enter case 1 then it will execute Area of Circle. If case 2 then even Area of Triangle
otherwise it will add the sum of 2 numbers.
Q2. WAP of parameterized constructor in Java.
SET-B
Experiments:
1. Aim
Creating java program and constructors.
2. Task to be done-
WAP if we enter case 1 then it will execute Area of Circle. If case 2 then
even Area of Triangle otherwise it will add the sum of 2 numbers.
WAP of parameterized constructor in Java.
3. Code of experiment
import java.util.Scanner;
int ch;
System.out.println("\t\t//Enter Your Choice//\t\t");
System.out.println("Enter 1 For Area Of Circle ");
System.out.println("Enter 2 For Area Of Triangle ");
System.out.println("By default It Will Add your number ");
Scanner obj3=new Scanner(System.in);
ch=obj3.nextInt();
switch(ch)
{
case 1:
int r;
int sum;
case 2:
int b;
int h;
float sum1;
System.out.println("Enter base of triangle : ");
Scanner base= new Scanner(System.in);
b=base.nextInt();
default:
int a;
int a2;
float sum2;
System.out.println("Enter the first Number : ");
Scanner obj1= new Scanner(System.in);
a=obj1.nextInt();
System.out.println("Enter the Second Number : ");
Scanner obj= new Scanner(System.in);
a2=obj.nextInt();
System.out.println(a+a2);
break;
}
}
}
Experiment -2
Car(String carColor)
{
this.carColor = carColor;
}
Output 4