0% found this document useful (0 votes)
88 views6 pages

MST LAB Worksheet

This document contains instructions for a practical examination in Internet Programming Lab for BCA semester 4 students. It provides two sets of experiments for students with even and odd user IDs to attempt. Set A includes programs to find the greater of two numbers or check even/odd, and a default constructor. Set B includes programs to calculate the area of a circle or triangle, or add two numbers, and a parameterized constructor. The document includes code for the area calculation program and constructors with outputs.

Uploaded by

RK HealingPower
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views6 pages

MST LAB Worksheet

This document contains instructions for a practical examination in Internet Programming Lab for BCA semester 4 students. It provides two sets of experiments for students with even and odd user IDs to attempt. Set A includes programs to find the greater of two numbers or check even/odd, and a default constructor. Set B includes programs to calculate the area of a circle or triangle, or add two numbers, and a parameterized constructor. The document includes code for the area calculation program and constructors with outputs.

Uploaded by

RK HealingPower
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Chandigarh University

University Institute of Computing


MST Practical Examination
March, 2022
Internet Programming Lab (20CAP-255)

Course: BCA Semester-4


MM: 6 Duration: 1 hour
UID- 20BCA1177

Note:

1. Attempt the questions that are assigned to you and you have executed.

2. Both questions are compulsory.

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;

public class area {

public static void main(String[] args)


{

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;

System.out.println("Enter Radius of Circle : ");


Scanner radius= new Scanner(System.in);
r=radius.nextInt();
sum=22/7*r*r;
System.out.println("The area Of Circle Is "+ sum);
break;

case 2:
int b;
int h;
float sum1;
System.out.println("Enter base of triangle : ");
Scanner base= new Scanner(System.in);
b=base.nextInt();

System.out.println("Enter height of Triangle : ");


Scanner height= new Scanner(System.in);
h=height.nextInt();
sum1=(b*h)*1/2;
System.out.println("The area Of Tiangle Is "+ sum1);
break;

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

public class Car


{
String carColor;
Car()
{
System.out.println("No argument Constructor of Car class called");
}

Car(String carColor)
{
this.carColor = carColor;
}

public void disp()


{
System.out.println("Color of the Car is : "+carColor);
}
public static void main(String args[])
{
//Calling the No argument constructor
Car c1 = new Car();

//Calling the parameterized constructor


Car c2 = new Car("Blue");
c2.disp();
}
Flowchart-2
Output-1
Area of circle

Area of Triangle Output-2


Default Output-3

Output 4

You might also like