Академический Документы
Профессиональный Документы
Культура Документы
SUBMITTED TO
Mr.Kulwinder Singh Asst. Professor CSE Deptt.
SUBMITTED BY
Pankaj Gill 11/CSE/168 CSE-B
PANKAJ GILL
INDEX
Aim
1. 2. Write a simple java program Write a program to show conversion Temperature from Celsius to Fahrenheit and Fahrenheit to Celsius Write a program to find the no and sum of all integers greater than 100 and less than 200 that are divisible by 7. Write a program to show a Grading system Write a program to print a format using * in increasing order Write a program to find out some of digits of any integer number Write a program to show the Multiplication table Write a program to show Constructor Method Write a program to show Method Overloading Write a program to show Method Overriding Write a program to show Polymorphism using Inheritance Write a program to show Inheritance Write a program to show Swapping of two Strings Write a program to show Multiplication of two Matrices Show the Life Cycle of an Applet Write a program to show a simple Applet
Page
1 2
Remarks
3.
8 10 12 14 16 18 20 22 25 27 30 34 38
PANKAJ GILL
PROGRAM NO. 1
PANKAJ GILL
1
11/CSE/168
OUTPUT
PANKAJ GILL
2
11/CSE/168
Write a program to show conversion Temperature from Celsius to Fahrenheit and Fahrenheit to Celsius
Import.java.util.*; class Temp { public static void main(String args[]) IOException { Scanner cin=new Scanner(System.in); intch; System.out.println("\n Press 1 for Centigrate to Farnhit OR 2 for Farnhit to Centigrate\n"); ch=cin.nextInt(); if(ch==1) { Scanner cin1=new Scanner(System.in); System.out.println("Enter temp in centigrate"); float c; float f; c=cin1.nextFloat(); f=(9*c+160)/5; System.out.println( "The temperature in Fahrenheit scale is :"+f); //throws
PROGRAM NO. 2
PANKAJ GILL
3
11/CSE/168
PANKAJ GILL
4
11/CSE/168
OUTPUT
PANKAJ GILL
5
11/CSE/168
Write a program to find the no and sum of all integers greater than 100 and less than 200 that are divisible by 7.
classFindSumIntCompute { public static void main(String[] args) { int sum = 0; for (inti=100; i<=200; i++) { if (i % 7 == 0) { System.out.println(i); sum += i; } } System.out.println("Sum of all integers greater than 100 and less than 200 that are divisible by 7 is " + sum); } }
PROGRAM NO. 3
PANKAJ GILL
6
11/CSE/168
OUTPUT
PANKAJ GILL
7
11/CSE/168
PROGRAM NO. 4
Scanner cin=new Scanner(System.in); inti; i=cin.nextInt(); if(i>=81 && i<=100) { System.out.println("Grade=A"); } else if(i>=61 && i<=80) { System.out.println("Grade=B"); } else if(i>=41 && i<=60) { System.out.println("Grade=C"); } else if(i>=0 && i<=40) { System.out.println("Grade=D"); } } }
PANKAJ GILL
8
11/CSE/168
OUTPUT
PANKAJ GILL
9
11/CSE/168
PROGRAM NO. 5
PANKAJ GILL
10
11/CSE/168
OUTPUT
PANKAJ GILL
11
11/CSE/168
PROGRAM NO. 6
PANKAJ GILL
12
11/CSE/168
OUTPUT
PANKAJ GILL
13
11/CSE/168
PROGRAM NO. 7
PANKAJ GILL
14
11/CSE/168
OUTPUT
PANKAJ GILL
15
11/CSE/168
PROGRAM NO. 8
//Default Constructer
PANKAJ GILL
16
11/CSE/168
OUTPUT
PANKAJ GILL
17
11/CSE/168
PROGRAM NO. 9
PANKAJ GILL
18
11/CSE/168
OUTPUT
PANKAJ GILL
19
11/CSE/168
PROGRAM NO. 10
PANKAJ GILL
20
11/CSE/168
OUTPUT
PANKAJ GILL
21
11/CSE/168
PROGRAM NO. 11
PANKAJ GILL
22
11/CSE/168
Description of Program:We have created object of class C only but due to polymorphism we are able to refer to Class a and class B also i.e. If we derive many classes from a base class then we can refer to any class by creating object of Derived Class (Child class).
PANKAJ GILL
23
11/CSE/168
OUTPUT
PANKAJ GILL
24
11/CSE/168
PROGRAM NO. 12
} class Test { public static void main(String args[]) { Child obj=new Child(); obj.Show(); System.out.println("child has takken parent's properties"); } }
PANKAJ GILL
25
11/CSE/168
OUTPUT
PANKAJ GILL
26
11/CSE/168
PROGRAM NO. 13
PANKAJ GILL
27
11/CSE/168
PANKAJ GILL
28
11/CSE/168
Output
PANKAJ GILL
29
11/CSE/168
PROGRAM NO. 14
PANKAJ GILL
30
11/CSE/168
PANKAJ GILL
31
11/CSE/168
System.out.print("\n"); } } } }
PANKAJ GILL
32
11/CSE/168
OUTPUT
PANKAJ GILL
33
11/CSE/168
PROGRAM NO. 15
public class AppletLifeCycleExample extends Applet { Label l1,l2,l3,l4,l5; public void init() { super.init(); //init method is called first.
PANKAJ GILL
34
11/CSE/168
} }
Description
Each Java applet goes through a sequence of stages. They are created (initialized), displayed (painted),paused while off screen (stopped, started) and finally removed (destroyed) when over.
PANKAJ GILL
35
11/CSE/168
PANKAJ GILL
36
11/CSE/168
OUTPUT
PANKAJ GILL
37
11/CSE/168
PROGRAM NO. 16
PANKAJ GILL
38
11/CSE/168
OUTPUT
PANKAJ GILL
39
11/CSE/168