source code name: KeyDemo4.java import java.awt.*; import java.awt.event.*; class KeyDemo4 extends Frame implements KeyListener { public KeyDemo4() { addKeyListener(this); } public void keyPressed(KeyEvent ke) { System.out.println("key is Pressed"); char ch=ke.getKeyChar(); Graphics g=getGraph…
Read moresource code name: btenabledisable.java import java.awt.*; import java.awt.event.*; class btenabledisable extends Frame implements ActionListener { TextField t1; public btenabledisable() { FlowLayout fl=new FlowLayout(1,20,10); setLayout(fl); t1=new TextField(25); Button b1=new Button("enable&q…
Read more7) Display Circle , Rectangle and Square as selecting keys c , r and s using Key Event.
soruce code name: KeyDemo3.java import java.awt.*; import java.awt.event.*; class KeyDemo3 extends Frame implements KeyListener { public KeyDemo3() { addKeyListener(this); } public void keyPressed(KeyEvent ke) { System.out.println("key is Pressed"); char ch=ke.getKeyChar(); Graphics g=getGr…
Read more6) Program display entered key's Character , it's ascii code and text using Key Event
source code name: KeyDemo2.java import java.awt.*; import java.awt.event.*; class KeyDemo2 extends Frame implements KeyListener { public KeyDemo2() { addKeyListener(this); } public void keyPressed(KeyEvent ke) { System.out.println("key is Pressed"); char ch=ke.getKeyChar(); int n=ke.getKeyCod…
Read moresource code name: KeyDemo1.jav a import java.awt.*; import java.awt.event.*; class KeyDemo1 extends Frame implements KeyListener { public KeyDemo1() { addKeyListener(this); } public void keyPressed(KeyEvent me) { System.out.println("key is Pressed"); } public void keyReleased(KeyEvent me){ S…
Read more1) Write a C++ program that finds Volume of Cube, Cylinder and Box using function overloading.
source code name: FNOVER1.CPP #include<stdio.h> #include<conio.h> #include<iostream.h> void volume(int s) { cout<<" \n volume of Cube "<< s*s*s; } void volume(int r, int h) { cout<< "\n volume of Cylinder: "<<3.142*r*r*h; } void volume(long l, int b, int h…
Read moresource code name: MouseDemo3.java import java.awt.*; import java.awt.event.*; class MouseDemo3 extends Frame implements MouseListener { int x,y; public MouseDemo3() { addMouseListener(this); } public void mousePressed(MouseEvent me) { x=me.getX(); y=me.getY(); repaint(); } public void mouseReleased(Mou…
Read moresource code name: MouseDemo2.java import java.awt.*; import java.awt.event.*; class MouseDemo2 extends Frame implements MouseListener { String str="wel come"; int x,y; public MouseDemo2() { addMouseListener(this); } public void mousePressed(MouseEvent me) { System.out.println("mouse is …
Read moresource code name: MouseDemo1.java import java.awt.*; import java.awt.event.*; class MouseDemo1 extends Frame implements MouseListener { public MouseDemo1() { addMouseListener(this); } public void mousePressed(MouseEvent me) { System.out.println("mouse is Pressed"); } public void mouseReleased…
Read moresource code name: TextComboDemo.java import java.awt.*; import java.util.*; import java.awt.event.*; class TextComboDemo extends Frame { Font f1=new Font("High Tower Text",Font.BOLD,18); TextField t1; Choice ch; public TextComboDemo() { FlowLayout fl=new FlowLayout(); setLayout(fl); Label…
Read more3) Write a C program that finds and display discount amount while purchasing items.
source code name: discount.C void main() { int qty,rt,amt,amtpaid; int dis=0; clrscr(); printf(" enter quantity and rate of items: \n"); scanf("%d%d",&qty,&rt); amt=qty*rt; if(amt>=1000) dis=amt*0.1; else printf("\n sorry no discount , purchase some items "); amtpaid=amt-dis; …
Read more6) Write a C program that finds sum of digits of a number using Recursive function.
source code name: RECSUM.C #include<stdio.h> int sumrec(int n) { int sum=0; int d; d=n%10; sum=sum+d; if(n==0) return 0; else { sum=sum+sumrec(n/10); } return sum; } int main() { int n,s; //clrscr(); printf(" enter any no: \n"); scanf("%d",&n); s=sumrec(n); printf(" sum of digits: …
Read moresource name: max3.C #include<stdio.h> void main() { int a,b,c; clrscr(); printf(" enter any three numbers: \n "); scanf("%d%d%d", &a, &b, &c); if(a>b && a>c) printf(" \n maximum is A number=%d ",a); if(b>c) printf(" \n maximum is B number=%d &quo…
Read moresouce code: dateshow.java import java.awt.*; import java.util.*; import java.awt.event.*; class dateshow extends Frame { Font f1=new Font("High Tower Text",Font.BOLD,18); Label lb; public dateshow(){ setLayout(null); lb=new Label("date"); // create label Button b1=new Button(&q…
Read moresource code : randomcolor.java import java.awt.*; import java.awt.event.*; class randomcolor extends Frame { Color col=Color.green; public randomcolor(){ setLayout(null); Button b1=new Button("randomcolor");//create button b1.setBounds(100,80,100, 40); add(b1);//adding button on fra…
Read moresource code: recfact.c #include<stdio.h> int recfact(int n) { int f=1; if(n==0) return 1; else f=n*recfact(n-1); return f; } int main() { int n,fv; //clrscr(); printf(" enter any no: \n"); scanf("%d",&n); fv=recfact(n); printf(" factorial value: %d ",fv); //getch(); return 0…
Read morevoid fact(int n) { int f=1; for(;n>0;n--) f=f*n; printf(" factorial value: %d ",f); } void main() { int n,f; clrscr(); printf(" enter any no: \n"); scanf("%d",&n); fact(n); getch(); } output: enter any no: 5 factorial value: 120
Read more4) Write a program to finds and display divisible by 7 numbers 100 to 200 and sum of it.
souce code: divisible7.c #include<stdio.h> void main() { int n,sum=0; clrscr(); n=100; printf(" numbers divisble by 7 from 100 to 200 : \n "); while(n<200) { if(n%7==0) { printf(" %d ",n); sum=sum+n; } n++; } printf(" \n sum =%d ",sum); getch(); } output:
Read moresource code: OOP1.cpp #include<stdio.h> #include<conio.h> #include<iostream.h> class simple { int a,b; public: void get(int m, int n) { a=m; b=n; } void show() { cout<<" a: "<<a<<" b: "<<b; } } ; void main() { clrscr(); cout<<"object oriented pr…
Read moresource code: primefn.c void prime(int n) { int d=2; while(d<n) { if(n%d==0) { break; } else d++; } if(n==d) printf(" %d ",n); } void main() { int k; clrscr(); printf(" function for prime numbers 2 to 100 \n"); for(k=2;k<100;k++) prime(k); getch(); } output: function for prime numbers 2 to…
Read more2) Write C++ program that accepts 4 subjects marks and finds total and average marks.
#include<stdio.h> #include<conio.h> #include<iostream.h> void main() { int s1,s2,s3,s4,total,avg; clrscr(); cout<<"enter 4 subjects marks: "; cin >> s1>>s2>>s3>>s4; total=s1+s2+s3+s4; avg=total/4; cout<<"total : "<<total<<" a…
Read more#include<stdio.h> #include<conio.h> #include<iostream.h> void main() { int n,sq,c; clrscr(); cout<<"enter any no: "; cin>>n; sq=n*n; c=n*n*n; cout<<"square : "<<sq<<" cube "<<c; getch(); } output: enter any no: 7 square: 49 cube: 343
Read moresource code: calc.java import java.awt.*; import java.awt.event.*; class calc extends Frame implements ActionListener { TextField t1,t2, t3; public calc() { FlowLayout fl=new FlowLayout(); setLayout(fl); Label l1=new Label("enter a no:"); Label l2=new Label("enter b no"); Label l3=new Label("…
Read moresource code: fillrect.java import java.awt.*; import java.awt.event.*; class fillrect extends Frame implements ActionListener { Color col=Color.pink; public fillrect() { FlowLayout fl=new FlowLayout(); setLayout(fl); Button b1=new Button("red"); Button b2=new Button("green"); Button b3=new Button(…
Read moresource code: login.java import java.awt.*; import java.awt.event.*; class login extends Frame implements ActionListener { TextField t1,t2; public login() { FlowLayout fl=new FlowLayout(); setLayout(fl); Label l1=new Label("user name"); Label l2=new Label("password"); t1=new TextField(15); t2=new…
Read more3) write windows programs that fills different colors to Rectangle, Circle , Square and Oval.
source code : fillShapes.java import java.awt.*; class fillShapes extends Frame { public void paint(Graphics g) { g.setColor(Color.blue); g.fillRect(80,120,50,50); g.setColor(Color.pink); g.fillRect(150,150,50,150); g.setColor(Color.red); g.fillOval(200,50,50,50); g.setColor(Color.green); g.fillOval(225,200,100,50);…
Read more2) Write a window program that display Line , Rectangle , Square , Circle and Ellipse shapes.
source code: drawShapes.java import java.awt.*; class drawShapes extends Frame { public void paint(Graphics g) { g.drawLine(100,100,50,100); g.drawRect(80,120,50,50); g.drawRect(50,200,50,150); g.drawOval(200,50,50,50); g.drawOval(200,200,100,50); } public static void main(String as[]) { drawShapes f=new drawShapes…
Read more1) Write a Windows program that display three different text with three different Fonts types.
source code : drawingtext.java import java.awt.*; class drawingtext extends Frame { Font f1=new Font("Courier",Font.BOLD,32); Font f2=new Font("Edwardian Script ITC",Font.BOLD,36); Font f3=new Font("Times New Roman",Font.ITALIC,50); public void paint(Graphics g) { g.setFont(f1); g.draw…
Read moreimport java.io.*; class filedemo1 { public static void main(String as[]) { System.out.println("file related program"); int n; try { FileInputStream fis=new FileInputStream("input.txt"); FileOutputStream fos=new FileOutputStream("newdata.txt"); int c; …
Read moreThe program should accept command line argument, if it file then File name display and if it Directory then contains of directory is displays. import java.io.*; public class FileDemo { public static void main(String as[]) { File f=null; try { f=new File(as[0]); System…
Read moreimport java.io.*; class Basicopdemo { public static void main(String as[]) { double a,b; DataInputStream dis; try { dis=new DataInputStream(System.in); do { System.out.println("enter first value a:"); String str1=dis.readLine(); a=Double.parseDouble(str1); System.out.println(&…
Read moreimport java.io.*; class filedemo1 { public static void main(String as[]) { double r; DataInputStream dis; try { dis=new DataInputStream(System.in); do { System.out.println("enter radius:"); String rad=dis.readLine(); r=Double.parseDouble(rad); if(r>0.0) { double ac=3.14…
Read moreclass exceptiondemo1 { public static void main(String as[]) { System.out.println("exception handling program"); int a,b,add,sub,mul,div; try { a=Integer.parseInt(as[0]); b=Integer.parseInt(as[1]); add=a+b; sub=a-b; mul=a*b; div=a/b; System.out.println("add: "+add+&…
Read more