Subhasish JAVA
Subhasish JAVA
8. Take your roll no.(only last two digits), name, java lab paper code and date; initialize 12
them within constructor and print.
9. Using nested if-else do the following,Take the amount of salary and working hour of an 13
employee. If i)Salary>20K and <30K and working hour>=7 hr, increase salary by 20%
and show the new salary ii)Salary>20K and <30K and working hour>=5 hr but <7 hr,
increase salary by 10% and show the new salary iii)Salary>20K and <30K and working
hour>3 hr but <5 hr, increase salary by 5% and show the new salary If- i)Salary>8K and
<20K and working hour>7-8 hr, increase salary by 15% and show the new salary
ii)Salary>8K and <20K and working hour>=5 hr but <7 hr, increase salary by 10% and
show the new salary iii)Salary>8K and <20K and working hour>3 hr but <5 hr, print “no
increment” in salary
10. (21*3)+85%7-{66+(39-29-24)} 15
11. Create a class named ‘Flower’ with instance variables ‘color’, ’season’, ’smell’ and a 16
method common for every flower. Create two subclasses named ‘Rose’ and
‘Sunflower’. Initialize those instance variables of parent class into subclasses and also
create new methods correspond to each child class. Show the instance variables and
invoke methods creating object of child class
12. Create a class ‘Phone’. Derive two classes ‘Telephone’ and ‘Mobile’. Put methods 18
within those classes to print separate features of Telephone and Mobile like- whether
wireless or not , have display or not etc. . Derive a class from ‘mobile’ class named
‘iPhone’ and mention methods to print the basic features of that model of mobile. Invoke
the methods of parent and child class by creating object of child class.
13. Create a class ‘Student’. Take values from user. Create methods with name 20
‘calGrade’ such that-If dept= ‘English’, grade=( score + 90% of attendance)If
Page 2 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
17. Create a class ‘Employee’ with variables- name, dept, designation, initialize them and 26
define methods to print the information. Extend a class from employee class with two
new variables ID, salary. Now override the super class method to print parent class
variables as well as child class variables. Remember: you can only create object of sub
class.
18. Do the same as previous program but now create a constructor to initialize the variables. 27
Then in subclass create a constructor to initialize new(additional ) variables. Lastly call
the method to show the member variable values.
19. Make a package named ‘firstPkg’ in which create a class and define a method. The 28
method takes two numbers as parameters and subtracts the smaller number from the
bigger one. Now in your program call that method and do the same with your values
given from user
20. Create a package ‘firstPkg’ where put a class ‘firstmtd’ and a method with some print 29
statement and create a package ‘MyPkg’ where put a class ‘Mymtd’ where we have main
method. Call the method from main method creating object. Show the result.
21. Create a package ‘MyPkg1’ where create a method within a class with some statements 30
inside it. Mention the method as ‘protected’. Then create a package ‘MyPkg2’ where
create a class ‘Mymtd’ which will inherit the class of ‘MyPkg1’. Now invoke the method
from main method . Show the result.
22. Let the features of a class named ‘Animal’ succeeded into class ‘Cat’ and the features of 32
Cat into class ‘Tiger’. Cat has two methods that prints “It is a domestic animal” and “It is
carnivorous” respectively. Now tiger is not domestic, so inherit Tiger in a way that this
method can’t be acquired from Cat into Tiger.
23. Assignment Take an array from user and print the even and odd numbers from the array 32
3
24. With a basic try catch block, show exception handling. 33
Page 3 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
26. WAP in java to throw any checked exception using ‘throws’ keyword. 35
27. Write an applet to create three buttons to change the background color. 35
28. Write an applet in AWT to take user name and phone number from user and print 37
those.
30. Take two values and find the bigger one between then using applet 39
31. Using java AWT make two radio buttons named ‘BCA’ and ‘MCA’, to take the steam of 41
a student and three check box named ‘Java’ , ‘C’ and ‘C++’ , to take the subject of a
student.
Assignment-1
1. WAP in Java to make a simple calculator using switch case.
Code:-
Page 4 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
import java.util.Scanner;
class Switchcalc {
public static void main(String[] args) {
int a,b,ch;
System.out.print("Enter the number of A: ");
Scanner r=new Scanner(System.in);
a=r.nextInt();
System.out.print("Enter the number of B: ");
Scanner r1=new Scanner(System.in);
b=r1.nextInt();
System.out.print("\n");
System.out.print("1. Addition \n");
System.out.print("2. Subtraction \n");
System.out.print("3. Multiplication \n");
System.out.print("4. Division \n");
System.out.print("\n");
System.out.print("Enter your choice: ");
Scanner ref=new Scanner(System.in);
ch=ref.nextInt();
switch (ch)
{
case 1: int add= a+b;
System.out.print("Sum = " + add);
break;
case 2: int sub= a-b;
System.out.print("Sub = " + sub);
break;
case 3: int mul= a*b;
System.out.print("Mul = " + mul);
break;
case 4: int div=a/b;
System.out.print("Div = " + div);
break;
default: System.out.print("Wrong Choice !");
}
System.out.print("\n");
System.out.print("Out of the Switch Case.......");
}
}
Output:-
Page 5 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Page 6 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
else{
System.out.print("Not a given Score");
}
}
}
Output:-
int n = 5;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
System.out.print("\n");
}
}
}
Output:-
Page 7 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
int n = 9;
for (int i = 1; i <= n; i=i+2) {
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
System.out.print("\n");
}
}
}
Output:-
4. Take a string from user and show whether the string is palindrome or
not.
Code:-
import java.util.Scanner;
class palindrome {
public static void main(String[] args) {
String a;
System.out.print("Enter the String: ");
Scanner r=new Scanner(System.in);
a=r.nextLine();
boolean flag = true;
Page 8 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
a = a.toLowerCase();
for(int i = 0; i < a.length()/2; i++){
if(a.charAt(i) != a.charAt(a.length()-i-1)){
flag = false;
break;
}
}
if(flag)
System.out.println("Given string is palindrome");
else
System.out.println("Given string is not a palindrome");
}
}
Output:-
5. Take a string from user and find the reverse of the string.
Code:-
import java.util.Scanner;
class Reverse {
public static void main(String[] args) {
String a,b="";
int l;
System.out.print("Enter the String: ");
Scanner r=new Scanner(System.in);
a=r.nextLine();
l=a.length();
for(int i=l-1;i>=0;i--)
{
b=b+a.charAt(i);
}
System.out.print(b);
}
}
Output:-
Page 9 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
6. Take strings from user and apply these below String class methods-
isEmpty( ), trim( ), compareToIgnoreCase( ),substring( ),
replaceFirst( ), replaceAll( ), indexOf( ),contains( ), valueOf( ) and
split( )
Code:-
import java.util.Scanner;
public class StringMethodsDemo {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
// isEmpty()
boolean isEmpty = inputString.isEmpty();
System.out.println("isEmpty(): " + isEmpty);
// trim()
String trimmedString = inputString.trim();
System.out.println("trim(): " + trimmedString);
// compareToIgnoreCase()
System.out.print("Enter another string to compare: ");
String compareString = scanner.nextLine();
int comparisonResult = inputString.compareToIgnoreCase(compareString);
System.out.println("compareToIgnoreCase(): " + comparisonResult);
// substring()
String str3 = new String("Rs 1000");
System.out.println("substring(): " + str3.substring(3));
// replaceFirst()
System.out.print("Enter the regular expression for replaceFirst: ");
String regex = scanner.nextLine();
System.out.println("replaceFirst(): " + regex.replaceFirst("aa", "zz"));
// replaceAll()
String s1="Java is a good language";
String replaceString=s1.replaceAll("a","e");
System.out.println("replaceAll(): " + replaceString);
// indexOf()
String searchStr = "Hello planet earth, you are a great planet.";
System.out.println("indexOf(): " + searchStr.indexOf("e",2));
// contains()
System.out.print("Enter the substring to check for contains: ");
String subStr = scanner.nextLine();
System.out.println("contains(): " + subStr.contains("Hel"));
// valueOf()
int value=30;
Page 10 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
String s2=String.valueOf(value);
System.out.println("valueOf(): " + s2+10);
// split()
String text = "Java is a fun programming language";
String[] result = text.split(" ");
System.out.print("result = ");
for (String str : result)
{
System.out.print(str + ", ");
}
scanner.close();
}
}
Output:-
String a = "hello";
String b=new String("hello");
if(a==b)
{
System.out.print("True \n");
}
Page 11 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
else
{
System.out.print("False \n");
}
if(a.equals(b))
{
System.out.print("True \n");
}
else
{
System.out.print("False \n");
}
}
}
Output:-
8. Take your roll no.(only last two digits), name, java lab paper code
and date; initialize them within constructor and print.
Code:-
class studentdetails
{
int roll;
String name,jlpcode,date;
studentdetails(int Roll,String Name,String Jlpcode,String Date)
{
roll = Roll;
name = Name;
jlpcode = Jlpcode;
date = Date;
}
void display()
{
System.out.print("\n Student Roll number is: " + roll);
System.out.print("\n Student Name is: " + name);
System.out.print("\n Student java lab paper code number is: " + jlpcode);
System.out.print("\n Lab paper submitted date is: " + date);
}
}
Page 12 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
class demo9
{
public static void main(String[] args)
{
studentdetails s = new studentdetails(43,"Saikat Dey","MCA20-293","02/06/2023");
s.display();
}
}
Output:-
Page 13 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Page 14 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
(21*3)+85%7-{66+(39-29-24)}
Code:-
class Eevaluation
{
static int expression()
{
int s1 = multiply(21,3);
int s2 = module(85,7);
int s3 = subtract(39,29,24);
int s4 = add(66,s3);
int s5 = subtract(s4,s1);
int s6 = add(s1,s2);
int s7 = subtract(s6,s5);
return s7;
}
static int multiply(int a,int b)
{
return a*b;
}
static int module(int a,int b)
{
return a%b;
}
Page 15 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Assignment-2
1. Create a class named ‘Flower’ with instance variables ‘color’,
’season’, ’smell’ and a method common for every flower. Create two
subclasses named ‘Rose’ and ‘Sunflower’. Initialize those instance
variables of parent class into subclasses and also create new methods
correspond to each child class. Show the instance variables and
invoke methods creating object of child class.
Code:-
class Flower
{
String color,Season,Smell;
void flo()
{
System.out.print("\n Name of the Flower ------- ");
Page 16 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
}
}
class Rose extends Flower
{
@Override
void flo()
{
String name = "Rose";
color = "Red";
Season = "Winter";
Smell = "floral and tea aromas to spicy,fruity,and musky scents";
super.flo();
System.out.print("is: " + name);
System.out.print("\n Rose color is: "+color);
System.out.print("\n Season is: "+Season);
System.out.print("\n Smell of the flower rose: "+Smell);
}
}
class Sunflower extends Flower
{
@Override
void flo()
{
String name = "Sunflower";
color = "Yellow";
Season = "Summer and into autumn";
Smell = "Slightly sweet,grassy or hay-like aroma";
super.flo();
System.out.print("is: " + name);
System.out.print("\n Sunflower color is: "+color);
System.out.print("\n Season is: "+Season);
System.out.print("\n Smell of the flower Sunflower: "+Smell);
}
}
class demo
{
public static void main(String[] args)
{
Rose r = new Rose();
Sunflower r1 = new Sunflower();
r.flo();
r1.flo();
}
}
Page 17 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Output:-
Page 18 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
{
//@Override
void features()
{
//super.features();
System.out.print("\n Features of the Mobile----: ");
System.out.print("\n Mobile is an electronic device that use for conversations over great
distance.");
System.out.print("Mobile is a wireless device.");
System.out.print("Mobile have a display.");
}
}
class Iphone extends Mobile
{
@Override
void features()
{
super.features();
System.out.print("\n Features of the Iphone----: ");
System.out.print("\n 1. Iphone reveals the data collection.\n 2. Ihone restricts online
activities storage.\n 3. Apple app store offers secure apps.\n 4. Malware activities.\n 5. Iphone
shows if the mi or camera is open by any app.");
}
}
class demo1
{
public static void main(String[] args)
{
Iphone r = new Iphone();
Phone r1 = new Telephone();
r1.features();
r.features();
}
}
Output:-
Page 19 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
3. Create a class ‘Student’. Take values from user. Create methods with
name ‘calGrade’ such that-
a. If dept= ‘English’, grade=( score + 90% of attendance)
b. If dept= ‘Math’, grade=( score + 80% of attendance+
assignment marks)
c. If dept= ‘Physics’, grade=( score + assignment marks+
practical marks)
d. If dept= ‘Com. Sc., grade=( score + + 80% of attendance
+assignment marks+ practical marks)
Code:-
import java.util.Scanner;
class Student
{
private String dept;
private double score;
private double attendance;
private double assignmentMarks;
private double practicalMarks;
public Student(String dept, double score, double attendance, double assignmentMarks,
double practicalMarks)
{
this.dept = dept;
this.score = score;
this.attendance = attendance;
Page 20 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
this.assignmentMarks = assignmentMarks;
this.practicalMarks = practicalMarks;
}
public double calGrade()
{
double grade = 0.0;
if (dept.equals("English"))
{
grade = score + (0.9 * attendance);
}
else if (dept.equals("Math"))
{
grade = score + (0.8 * attendance) + assignmentMarks;
}
else if (dept.equals("Physics"))
{
grade = score + assignmentMarks + practicalMarks;
}
else if (dept.equals("Com. Sc.")) {
grade = score + (0.8 * attendance) + assignmentMarks + practicalMarks;
}
else
{
System.out.println("Invalid department!");
}
return grade;
}
}
Page 21 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Page 22 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
{
this.ID = ID;
this.name = name;
this.phoneNo = phoneNo;
this.address = address;
this.salary = salary;
this.department = department;
}
public void printData()
{
System.out.println("Employee Details:");
System.out.println("ID: " + ID);
System.out.println("Name: " + name);
System.out.println("Phone No: " + phoneNo);
System.out.println("Address: " + address);
System.out.println("Salary: " + salary);
System.out.println("Department: " + department);
}
}
class Manager implements Member
{
private int ID;
private String name;
private String phoneNo;
private String address;
private double salary;
private String department;
public Manager(int ID, String name, String phoneNo, String address, double salary, String
department)
{
this.ID = ID;
this.name = name;
this.phoneNo = phoneNo;
this.address = address;
this.salary = salary;
this.department = department;
}
public void printData()
{
System.out.println("Manager Details:");
System.out.println("ID: " + ID);
System.out.println("Name: " + name);
System.out.println("Phone No: " + phoneNo);
System.out.println("Address: " + address);
Page 23 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Page 24 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Page 25 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
{
Rose r = new Rose();
Sunflower s = new Sunflower();
r.showcolor();
s.showcolor();
}
}
Output:-
Page 26 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Page 27 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
}
class Emp1 extends Employees
{
String id;
long salary;
Emp1(String ID,long Salary) //parametarized constructor
{
id = ID;
salary = Salary;
}
public void show()
{
System.out.print("\n Employee ID is: "+id);
System.out.print("\n Employee salary is: "+salary);
}
}
public class demo5
{
public static void main(String[] args)
{
Emp1 e1 = new Emp1("S0167548",40000);
e1.display();
e1.show();
}
}
Output:-
Page 28 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
import java.util.Scanner;
class pkg1
{
int method_pkg(int a,int b)
{
int c;
c=a-b;
return c;
}
public static void main(String[] args)
{
pkg1 p = new pkg1();
int x,y,z;
System.out.print("\n Enter the Bigger number: ");
Scanner r = new Scanner(System.in);
x = r.nextInt();
System.out.print("\n Enter the Smaller number: ");
Scanner r1 = new Scanner(System.in);
y = r1.nextInt();
z = p.method_pkg(x,y);
System.out.print("result is: " + z);
}
}
Output:-
Code:-
package firstpkg;
public class pkg1
{
public int method_pkg(int a,int b)
Page 29 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
{
int c;
c=a-b;
return c;
}
}
package Mypkg;
import firstpkg.pkg1;
import java.util.Scanner;
public class Mymtd
{
public static void main(String[] args)
{
pkg1 p = new pkg1();
int x,y,z;
System.out.print("\n Enter the Bigger number: ");
Scanner r = new Scanner(System.in);
x = r.nextInt();
System.out.print("\n Enter the Smaller number: ");
Scanner r1 = new Scanner(System.in);
y = r1.nextInt();
z = p.method_pkg(x,y);
System.out.print("result is: " + z);
}
}
Output:-
Code:-
package Mypkg1;
public class pkg2
{
protected int method_pkg(int a,int b)
{
int c;
c=a-b;
return c;
}
}
package Mypkg2;
import Mypkg1.pkg2;
import java.util.Scanner;
class Mymtd extends pkg2
{
public static void main(String[] args)
{
Mymtd p = new Mymtd();
int x,y,z;
System.out.print("\n Enter the Bigger number: ");
Scanner r = new Scanner(System.in);
x = r.nextInt();
System.out.print("\n Enter the Smaller number: ");
Scanner r1 = new Scanner(System.in);
y = r1.nextInt();
z = p.method_pkg(x,y);
System.out.print("result is: " + z);
}
}
Output:-
12. Let the features of a class named ‘Animal’ succeeded into class
‘Cat’ and the features of Cat into class ‘Tiger’. Cat has two methods
Page 31 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Assignment-3
1. Take an array from user and print the even and odd numbers from the
array
Code:-
import java.util.Scanner;
class arrayoddeven
{
public static void main(String[] args)
{
int n,i;
System.out.print("\n Enter the array size: ");
Scanner r = new Scanner(System.in);
n = r.nextInt();
Page 32 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Page 33 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
try
{
System.out.print(str.toUpperCase());
}
catch(NullPointerException e)
{
System.out.print("\n Null can not be casted.");
}
}
}
Output:-
Page 34 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Page 35 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
<html>
<head>
<title> Print the User input</title>
<body>
<applet code = changecolor.class height = 400 width = 400>
</applet>
</body>
</html>
Output:-
6. Write an applet in AWT to take user name and phone number from
user and print those.
Page 36 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
Code:-
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class unapn extends Applet
implements ActionListener
{
TextField t1 = new TextField(20);
TextField t2 = new TextField(20);
Label l1 = new Label("User Name:");
Label l2 = new Label("Phone Number:");
Button b = new Button("Submit");
TextArea t3 = new TextArea(5,27);
Label l3 = new Label("Print:");
public void init()
{
add(l1);
add(t1);
add(l2);
add(t2);
add(b);
add(l3);
add(t3);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == b)
{
String Name = t1.getText();
String Phonenumber = t2.getText();
t3.setText("\n User Name is: " +Name+ "\n Phone Number is: " +Phonenumber);
}
}
}
<html>
<head>
<title> Print the User input</title>
<body>
<applet code = unapn.class height = 400 width = 400>
Page 37 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
</applet>
</body>
</html>
Output:-
Page 38 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
if(str!=null){
salary = Integer.parseInt(str);
}
else{
salary = 0;
}
}
catch(NumberFormatException e){
}
}
public void paint(Graphics g)
{
g.drawString("\n Employee name: " + ename,20,10);
g.drawString("\n Employee Designation: " + designation,20,30);
g.drawString("\n Employee Salary: " + salary,20,50);
}
}
<html>
<head>
<title> Print the User input</title>
<body>
<applet code = empdetails.class height = 400 width = 400>
<param name = "Employee name" value = "Ankit">
<param name = "Your Designation" value = "HR">
<param name = "Salary" value = 40000>
</applet>
</body>
</html>
Output:-
8. Take two values and find the bigger one between then using applet
Code:-
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
Page 39 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
<html>
<head>
<title> Find The biggest value</title>
<body>
Page 40 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
9. Using java AWT make two radio buttons named ‘BCA’ and ‘MCA’,
to take the steam of a student and three check box named ‘Java’ , ‘C’
and ‘C++’ , to take the subject of a student. Show the
outputs.Example: if you click on stream ‘MCA’ and choose subjects
‘C’ and ‘Java’
Code:-
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class streamlanguage extends Applet
implements ActionListener
{
String lang1,lang2,lang3,stream;
Label l1 = new Label("Strem:");
Label l2 = new Label("Language:");
CheckboxGroup cg1 = new CheckboxGroup();
Checkbox b = new Checkbox("BCA",cg1,false);
Checkbox b1 = new Checkbox("MCA",cg1,false);
//CheckboxGroup cg = new CheckboxGroup();
Checkbox c1 = new Checkbox("JAVA");
Checkbox c2 = new Checkbox("C");
Checkbox c3 = new Checkbox("C++");
TextArea t1 = new TextArea(5,27);
Button B = new Button("Submit");
public void init()
{
add(l1);
Page 41 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
add(b);
add(b1);
add(l2);
add(c1);
add(c2);
add(c3);
add(B);
add(t1);
B.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == B){
stream = cg1.getSelectedCheckbox().getLabel();
if (c1.getState()){
lang1 = "java";
t1.setText("\n Stream: " + stream + "\n Subject is: " + lang1);
}
else if(c2.getState()){
lang2 = "C";
t1.setText("\n Stream: " + stream + "\n Subject is: " + lang2);
}
else if(c3.getState()){
lang3 = "C++";
t1.setText("\n Stream: " + stream + "\n Subject is: " + lang3);
}
if (c1.getState() && c2.getState() && c3.getState()){
lang1 = "Java ";
lang2 = "C";
lang3 = "C++";
t1.setText("\n Stream: " + stream + "\n Subject is: " + lang1 + "\n " + lang2 + "\n" + lang3);
}
else if (c1.getState() && c2.getState()){
lang1 = "Java ";
lang2= "C ";
t1.setText("\n Stream: " + stream + "\n Subject is: " + lang1 + "\n " + lang2);
}
else if (c1.getState() && c3.getState()){
lang1 = "Java ";
lang3= "C++";
t1.setText("\n Stream: " + stream + "\n Subject is: " + lang1 + "\n " + lang3);
}
else if(c2.getState() && c3.getState()){
lang2 = "C";
Page 42 of 43
[Roll No:-504122011057] | [Subhasish Ghosh]
lang3= "C++";
t1.setText("\n Stream: " + stream + "\n Subject is: " + lang2 + "\n " + lang3);
}
}
}
}
<html>
<head>
<title> Print the User input</title>
<body>
<applet code = streamlanguage.class height = 400 width = 400>
</applet>
</body>
</html>
Output:-
Page 43 of 43