source file name: ProgressDemo.java import javax.swing.*; import java.awt.*; import javax.swing.event.*; public class ProgressDemo extends JFrame implements ChangeListener { JProgressBar pb; JSlider sd; public ProgressDemo() { setLayout(null); sd=new JSlider…
Read moresource file name: SliderDemo.java import javax.swing.*; import java.awt.*; import javax.swing.event.*; public class SliderDemo extends JFrame implements ChangeListener { JSlider sd; JLabel lb; public SliderDemo() { setLayout(new BorderLayout()); sd=new JSlider(…
Read moresource file name: swingbiodata.java import java.awt.*; import java.awt.event.*; import javax.swing.*; class swingbiodata extends JFrame implements ActionListener { JLabel l1,l2,l3,l4,l5,l6,l7,l8; JTextField t1,t2,t3; JTextArea ta; JList ls; JComboBox cb; JRadioButton cb1,cb2; JTable tb; public swingbiodata…
Read more6) Write a program that display static data and counting objects using Static function.
source file name: staticfn.cpp #include<conio.h> #include<iostream.h> class STest { static int cnt; int data; public: void setno() { data=++cnt; } void showdata() { cout<<" object number: "<<data<<endl; } static void display() { cout<<" count: "<<cnt <&…
Read moresource file name: staticdata.cpp #include<conio.h> #include<iostream.h> class Counter { static int cnt; int no; public: void getno(int m) { no=m; cnt++; } void getcount() { cout<<" count: "<<cnt<< " no: "<<no <<endl; } }; int Counter::cnt; void main() { cl…
Read moresource file name: friend3.cpp #include<conio.h> #include<iostream.h> class Average { int x,y,z; public: void setnos(int a, int b,int c) { x=a; y=b; z=c; } friend float avg(Average a); }; float avg(Average ob) { float r=(ob.x+ob.y+ob.z)/3; return r; } void main() { clrscr(); cout<<"Program on Fr…
Read moresource file name: friend2.cpp #include<stdio.h> #include<conio.h> #include<iostream.h> class Y; class X { int a; public: void setno(int m) { a=m; } friend void max(X,Y); }; class Y { int b; public: void setno(int n) { b=n; } friend void max(X,Y); }; void max(X x, Y y) { if(x.a>y.b) cout<<…
Read moresource file name: inline2.cpp #include<iostream.h> #include<conio.h> inline long sq(int m) { return m*m; } inline long cube( int n) { return n*n*n; } void main() { clrscr(); cout<<" Inline Functions program:"<<endl; cout<<" \n Square is : "<<sq(6); cout<<…
Read more1) Write a program that finds Multiplication and Division values using Inline function
source file name: inline1.cpp #include<iostream.h> #include<conio.h> inline long mul(int m, int n) { long X=m*n; return X; } inline float div(int m, int n) { float Y=m/n; return Y; } void main() { clrscr(); cout<<" Inline Functions program:"<<endl; cout<<" \n Multiplicati…
Read more6) Write a program to check whether the number entered is even ,odd , a positive , negative or zero.
source file name: psngodeven.C void main() { int n; clrscr(); printf("Odd or Even or +Ve or -Ve program"); printf("\n enter any number"); scanf("%d",&n); if(n%2==0) printf("\n Given no: %d is Even number",n ); else printf("\n Given no: %d is Odd number",n )…
Read moresource file name: oddeven.C void main() { int n; clrscr(); printf("Odd or Even program"); printf("\n enter any number"); scanf("%d",&n); if(n%2==0) printf("\n Given no: %d is Even number",n ); else printf("\n Given no: %d is Odd number",n ); getch(); } O…
Read more10) Write a program that find out the aggregate marks and percentage marks obtained by the student of five different subjects mark.
Program statement: If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100. source file name: avgpercent.C void mai…
Read more9) Write a program to interchange the contents of C and D without using temporary variable.
Program statement: Two numbers are input through the keyboard into two locations C and D. write a program to interchange the contents of C and D without using temporary variable. source file name: swap1.C void main() { int C,D; clrscr(); printf("Interchange of two variables program"); printf("\n ent…
Read moresource file name: friend1.cpp #include<stdio.h> #include<conio.h> #include<iostream.h> class Y; class X { int a; public: void setno(int m) { a=m; } friend void min(X,Y); }; class Y { int b; public: void setno(int n) { b=n; } friend void min(X,Y); }; void min(X x, Y y) { if(x.a<y.b) cout<<&q…
Read more8)Write a program to calculate simple interest. If Principal(P) , rate(R) and period (n) is input from the keyboard.
source file name: simpint.c void main() { long P,N,R; long SI; clrscr(); printf("\n enter deposited Amount(P) , rate (R) and no. of years(N): "); scanf("%ld%ld%ld",&P,&N,&R); SI=(P*N*R)/100; printf("\n Simple interest=Rs.%ld ",SI); getch(); } Output: 1. enter deposited Am…
Read more4) The operator overloading program that implements (/) sign to all values divided by given no.
source file name: optor4.cpp #include<stdio.h> #include<conio.h> #include<iostream.h> #include<math.h> class Sigma { int x,y,z; public: void getdata(int a, int b,int c) { x=a; y=b; z=c; } void show() { cout<<" "<<x <<" "<<y <<" "<…
Read more3) The operator overloading program that implements (*) sign to get square of all values .
source file name: optor3.cpp #include<stdio.h> #include<conio.h> #include<iostream.h> class Gamma { int x,y,z; public: void getdata(int a, int b,int c) { x=a; y=b; z=c; } void show() { cout<<" "<<x <<" "<<y <<" "<<z<<endl; } …
Read more1) The Operator overloading program that implements (-) sign to all values becomes negative.
source file name: optor1.cpp #include<stdio.h> #include<conio.h> #include<iostream.h> class Alpha { int x,y,z; public: void getdata(int a, int b,int c) { x=a; y=b; z=c; } void show() { cout<<" "<<x <<" "<<y <<" "<<z<<endl; } …
Read more2) The operator overloading program that implements (+) sign to get all values are double.
source file name: optor2.cpp #include<stdio.h> #include<conio.h> #include<iostream.h> class Beta { int x,y,z; public: void getdata(int a, int b,int c) { x=a; y=b; z=c; } void show() { cout<<" x: "<<x <<" y: "<<y <<" z: "<<z<<end…
Read moresource file name: sqcube.c void main() { int n,sq,c; clrscr(); printf("\n enter any number: "); scanf("%d",&n); sq=n*n; c=n*n*n; printf("\n Square =%d Cube=%d ",sq,c); getch(); } output: 1. enter any number:12 Square =144 Cube=1728 2. enter any number: 9 Square =81 Cube=7…
Read moresource file name: TextComponentDemo.java import java.awt.*; import java.awt.event.*; import javax.swing.*; class TextComponentDemo extends JFrame implements ActionListener { JTextField tf; JPasswordField pwf; JTextArea ta; JFormattedTextField ftf; public TextComponentDemo() { JPa…
Read moresource file name: EditorPaneDemo1.java import java.awt.*; import java.io.*; import java.net.*; import javax.swing.*; class EditorPaneDemo1 extends JFrame { JEditorPane ep; public EditorPaneDemo1() { ep = new JEditorPane(); JScrollPane sp=new JScrollPane(ep); add(sp, BorderLayout.CENTER); } public void lin…
Read moresource file name: ButtonTextPanelDemo.java import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; class ButtonTextPanelDemo extends JFrame implements ActionListener { public ButtonTextPanelDemo() { setLayout(null); JButton bt1=new JButton("RashtraGeet"); …
Read moresource file name: destructor.cpp #include<iostream.h> #include<conio.h> #include<math.h> int cnt; class beta { public: beta() { cnt++; cout<<"\n Object created No.: "<< cnt; } ~beta() { cout<<"\n Object destroyed No.: "<< cnt; cnt--; } } ;…
Read more5) Swing Program that display College Hierarchy structure using JTree , also display selected path in Text Box.
source file name: TreeDemo.java import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.tree.*; class TreeDemo extends JFrame { JTextField txt; public TreeDemo() { setLayout(null); JLabel lb=new JLabel(" Structure of DBJ College"); txt=new JTextField(100); DefaultMutabl…
Read moresource file name: TableDemo.java import java.awt.*; import java.awt.event.*; import javax.swing.*; class TableDemo extends JFrame { public TableDemo() { setLayout(null); JLabel lb=new JLabel("Student's Qualification"); String cols[]={"std.","name","year","grade…
Read moresource file name: roots.c Program: If coefficients of quadratic equation are input through keyboard. Write a program in C to find the roots of quadratic equation ax 2 +bx+c=0 whose coefficients are a, b and c. #include<math.h> void main() { int a,b,c; float R1,R2; //clrscr(); printf("\n enter coefficie…
Read more5) Write a program to finds the sum of digits of number.( Input a five digit number )
source file name: sumdigit.c void main() { int n,d1,d2,d3,d4,d5; int sum=0; clrscr(); printf("\n enter any 5 digit number: "); scanf("%d",&n); d1=n%10; n=n/10; d2=n%10; n=n/10; d3=n%10; n=n/10; d4=n%10; n=n/10; d5=n%10; sum=d1+d2+d3+d4+d5; printf("\n sum of digits=%d ",sum); getch()…
Read more4) Write a Program that finds area & perimeter of Rectangle and area & circumference of Circle.
source file name: areaRC.c Program: The length and breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area and perimeter of the rectangle, and the area and circumference of the circle. void main() { int len,bd,rad,arect,prect; float acir,cc; clrscr(); pr…
Read more3)Write a program to find the addition, subtraction, product, and division of two integers numbers.
source file name: basicop.c void main() { int a, b,add,sub,mul,div; clrscr(); printf("enter 2 numbers"); scanf("%d%d",&a,&b); add=a+b; sub=a-b; mul=a*b; div=a/b; printf("\n Addition=%d Substraction=%d",add,sub); printf("\n Multipication=%d Division=%d",mul,div); getch…
Read more5) Write a program that finds average of command line arguments which converted into double type numbers using method.
source file name: expdemo3.java class expdemo3 { public static void main (String args[]) { expdemo3 ob= new expdemo3(); double avg=ob.average(args); System.out.println("average of "+args.length+" number is: "+avg); } public double average (String as[]) { double sum =0.0 ; try { for( int i=0;i<…
Read more4) Write a Java program to find sum of command line numbers and count the Invalid integers entered.
source file name: expdemo.java class expdemo { public static void main (String as[]) { int n, cnt=0, sum=0; for(int i=0;i<as.length;i++) { try { n=Integer.parseInt(as[i]); sum= sum+n; } catch (NumberFormatException e) { //system.out.println("invalid integer:"); cnt++; } } System.out.println("Sum of…
Read moresource file name: AppletCanvasShapesDemo.java /* <applet code=AppletCanvasShapesDemo.class width=300 height=300 > </applet > */ import java.awt.*; import java.awt.event.*; import java.applet.*; public class AppletCanvasShapesDemo extends Applet implements ItemListener { Choice ch; Color col=null; ShapeD…
Read moresource file name: AppletStarDisplay.java /* <applet code=AppletStarDisplay.class width=300 height=300 > </applet > */ import java.awt.*; import java.awt.event.*; import java.applet.*; public class AppletStarDisplay extends Applet { public AppletStarDisplay() { } public void paint(Graphics g) { g.drawLine…
Read moresource file name: FrameImageDemo.java Note: Animals images source files exists on storage media. import java.awt.*; import java.awt.event.*; import java.applet.*; class FrameImageDemo extends Frame implements ItemListener { Choice ch; String str=""; Image img=null; public static void main(String[] a…
Read moreProgram Statement: Write a Applet program that calculates DA , HRA ,CCA and GS of employee using following information 1)if Basic Salary(BS) is <5000 then DA= 81% of BS 2) if BS is in range 5000 to 7000 then DA=51% of BS 3) if BS is > 7000 then DA=41% OF BS CCA =350/- HRA=15% OF BS source file name: AppletPar…
Read moresource file name: ButtonImageDemo.java import java.awt.*; import java.awt.event.*; import javax.swing.*; class ButtonImageDemo extends JFrame { ImageIcon cen=new ImageIcon("center.png"); ImageIcon east=new ImageIcon("east.jpg"); ImageIcon west=new ImageIcon("west.jpg"); ImageIcon nor…
Read moresource file name: SwingBorderDemo.java import java.awt.*; import java.awt.event.*; import javax.swing.*; class SwingBorderDemo extends JFrame { ImageIcon cen=new ImageIcon("center.png"); public static void main (String ob[]) { SwingBorderDemo f=new SwingBorderDemo(); f.setTitle(" Swing Button Border …
Read moresource file name: ButtonLabelDemo.java import java.awt.event.*; import javax.swing.*; class ButtonLabelDemo extends JFrame implements ActionListener { JLabel txtlb; public ButtonLabelDemo() { setLayout(null); JButton bt=new JButton("Click"); txtlb=new JLabel(); bt.setBounds(50,50…
Read more14) The windows program that displays shapes on Canvas using Card Layout Manager
source file name: CardLayoutDemo1.java import java.awt.*; import java.awt.event.*; class circle extends Canvas { public circle() { setBackground (Color.gray); setSize(300, 200); } public void paint(Graphics g) { g.setColor(Color.red); g.fillOval(100,100,80,80); } } class square extends C…
Read moresource file name: CardLayoutDemo.java import java.awt.*; import java.awt.event.*; public class CardLayoutDemo extends Frame implements ActionListener { CardLayout card; Button b1,b2,b3; Panel p; public CardLayoutDemo() { p=new Panel(); card=new CardLayout(40,30); p…
Read moresource file name: BorderDemo.java import java.awt.*; import java.awt.event.*; class BorderDemo extends Frame { String str="National Pledge"+ "\n India is my country and all Indians are my brothers and sisters."+ "\n I love my country and I am proud of its rich and varied heritage."+ &qu…
Read moresource file name: AppletSoundProgram.java First download below Sound files. audiotest DBJ AbhimanGeet /* <applet code=AppletSoundProgram.class width=300 height=300 > </applet> */ import java.applet.*; import java.awt.*; import java.awt.event.*; public class AppletSoundProgram extends Applet implements …
Read moresource file name: AppletParamDemo.java /* <html> <body> <applet code=AppletParamDemo.class width=550 height=300 > <param name="college" value="DBJ College" > // input value </applet> <body> <html> */ import java.awt.*; import java.applet.*; public class Ap…
Read moresource file name: AppletDemo.java /* <applet code=AppletDemo.class width=300 Height=300 > </applet> */ import java.applet.*; public class AppletDemo extends Applet { public void init() //initializtion { System.out.println("init() works "); } public void start() //start or resume exec…
Read moresource code name: itemevent3.java import java.awt.*; import java.awt.event.*; class itemevent3 extends Frame implements ItemListener { public static void main(String as[]) { itemevent3 f=new itemevent3(); f.setSize(400,400); f.setVisible(true); } Choice ch; TextField txt; public itemevent3() { FlowLayout fl=new Flo…
Read moresource code name: itemevent1.java import java.awt.*; import java.awt.event.*; class itemevent1 extends Frame implements ItemListener { public static void main(String as[]) { itemevent1 f=new itemevent1(); f.setSize(600,400); f.setVisible(true); } List ls; public itemevent1() { FlowLayout fl=new FlowLayout(); setLay…
Read moresource code name: itemevent2.java import java.awt.*; import java.awt.event.*; class itemevent2 extends Frame implements ItemListener { public static void main(String as[]) { itemevent2 f=new itemevent2(); f.setSize(400,400); f.setVisible(true); } Checkbox cb1,cb2; Label lb; public itemevent2() { FlowLayout fl=new F…
Read moresource code name: textevent1.java import java.awt.*; import java.awt.event.*; class textevent1 extends Frame implements TextListener { public static void main(String as[]) { textevent1 f=new textevent1(); f.setSize(500,300); f.setVisible(true); } TextField txt, outtxt; public textevent1() { FlowLayout fl=new FlowLa…
Read more3) To display Roman Equivalent of decimal number using O-O and Command Line Arguments
source code name: RomanConversionDemo.java class RomanConversionDemo { void roman(int n, char ch) { for(int i=1;i<=n;i++) System.out.print(ch+" "); } public static void main(String[] arg) { int th=0,fh=0,h=0,ft=0,ten=0,fv=0,s=0; int n; RomanConversionDemo ob=new RomanConversionDemo(); n=Integer.parseI…
Read more3) Convert Decimal number to Binary , Octal and Hexadecimal with Method Overloading.
source code name: ConversionDemo.java class ConversionDemo { void convert(int n, String s) // method over loaded with integer and String ( type 1) { int b=0,i; int rem[]=new int[10]; i=0; if(s.equals("binary")) { b=2; System.out.print("\nBinary Conversion: "); } if(s.equals("octal")) { b…
Read moresource code name: awtbiodata.java import java.awt.*; import java.awt.event.*; class awtbiodata extends Frame implements ActionListener { Label l1,l2,l3,l4,l5,l6,l7; TextField t1,t2,t3; TextArea ta; List ls; Choice ch; Checkbox cb1,cb2; public awtbiodata() { GridLayout fl=new GridLayout(0,2,10,10); setLa…
Read more