tag:blogger.com,1999:blog-30997039755114765992024-03-28T03:46:21.858-07:00TechieTopicsThis blog is mainly developed for individuals,who were interested in programming using C,C++,java and SQL.nikhilhttp://www.blogger.com/profile/01133260638044105562noreply@blogger.comBlogger91125tag:blogger.com,1999:blog-3099703975511476599.post-51978958103882539512012-10-21T22:04:00.000-07:002012-10-21T22:04:44.849-07:00Java program to implement multiple inheritance<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.io.*; <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">interface bookinfo<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ public
void getbookdata()throws IOException;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public
void putbookdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">interface basicinfo<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ public
void getbasicdata()throws IOException;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public
void putbasicdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">interface otherinfo<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ public
void getotherdata()throws IOException;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public
void putotherdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class book implements bookinfo,basicinfo,otherinfo<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ String
Bname,Bauthor, Blanguage,Bpublisher;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int Bprice, Bcopies,Byear;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> BufferedReader
br=new BufferedReader(new <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void getbookdata()throws IOException<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ System.out.println("Enter
the Book name:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Bname=br.readLine();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter
the author's name:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Bauthor=br.readLine();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void putbookdata()<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
System.out.print(Bname+"\t"+Bauthor+"\t");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void getbasicdata()throws IOException<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ System.out.println("Enter
the language:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Blanguage=br.readLine();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter
the published year:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Byear=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter
the price");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Bprice=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void putbasicdata()<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ System.out.print(Blanguage+"\t\t"+Byear+"\t"+Bprice+"\t");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void getotherdata()throws IOException<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ System.out.println("Enter
the number of copies:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Bcopies=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter
the publisher:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Bpublisher=br.readLine();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void putotherdata()<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ System.out.print(Bcopies+"\t"+Bpublisher+"\t\t");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class interfaceEg<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public static void main(String s[])throws
IOException<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
book it[];<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> BufferedReader br=new BufferedReader(new <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("How much
entries..?");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int k=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
it=new book[k];<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> for(int i=0;i<k;i++)<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { it[i]=new book();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
for(int i=0;i<k;i++)<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
int j=i+1;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("ENTER DETAILS OF
THE BOOK : "+j);<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].getbookdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].getbasicdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].getotherdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
System.out.println("\n\n***********-----------------Book <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
details-----------------************\n");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
System.out.println("Book\tAuthor\tLanguage\tYear\tPrice\tCopies<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
\tPublisher");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
System.out.println("............................................................................");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
for(int i=0;i<k;i++)<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].putbookdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].putbasicdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].putotherdata();<o:p></o:p></span></td></tr></table></div>
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 107%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
}}} </span></div>Unknownnoreply@blogger.com87tag:blogger.com,1999:blog-3099703975511476599.post-69606277093559677942012-10-21T21:14:00.000-07:002012-10-21T21:14:21.428-07:00HTML program to illustrate table tag and its attributes<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><html><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><body><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><h4>Cell that spans two columns:</h4><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><table border="1" bgcolor="green"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><tr><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"> <th>Name</th><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><th colspan="2">telephone</th><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"></tr><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><tr><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><td>Bill Gates</td><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><td>555 77 854</td><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><td>555 77 855</td><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"></tr><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"></table><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><h4>Cell that spans two rows:</h4><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><table border ="1" bgcolor="red"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><tr><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"> <th> First Name:</th><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><td>Bill Gates</td><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"></tr><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><tr><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><th rowspan="2">Telephone:</th><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><td>555 77 854</td><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"></tr><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><tr><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><td> 555 77 855</td><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"></tr><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"></table><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"></body><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"></html><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><u><br /></u></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><u>Output</u></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><u><br /></u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcFnRK2wnZbtvrs-usMA7hS9Syqu8d8pkVvtOl0k920aOTmSmW7yQRDp7YSJnPjBoaFO7RO0xMm02Ag6JvR0f2nYt9Tmqr2BO6py0LLDKCXQwojOcbgHsbzK5HgwIo7B2vc68QZZOguqwN/s1600/table.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcFnRK2wnZbtvrs-usMA7hS9Syqu8d8pkVvtOl0k920aOTmSmW7yQRDp7YSJnPjBoaFO7RO0xMm02Ag6JvR0f2nYt9Tmqr2BO6py0LLDKCXQwojOcbgHsbzK5HgwIo7B2vc68QZZOguqwN/s320/table.jpg" width="320" /></a></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 300.75pt;">
<span lang="EN-US" style="font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><u><br /></u></span></div>
</div>
Unknownnoreply@blogger.com43tag:blogger.com,1999:blog-3099703975511476599.post-5019746614894320122012-10-21T04:50:00.001-07:002012-10-21T21:29:13.569-07:00Java program to animate ball or moving ball using frame<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.awt.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
java.awt.event.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
java.applet.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
class movball extends Frame implements Runnable<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
int x,y;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Thread t;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> boolean flag;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public movball()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { x=0;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> y=250;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> addWindowListener(new mwa(this));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> t=new Thread(this);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> t.start();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> flag=false;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public void run()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { for(;;)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { try<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { repaint();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> x++;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Thread.sleep(100);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> catch(InterruptedException e)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> if(flag)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> break;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public void paint(Graphics g)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { g.drawOval(x,y,30,30);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public static void main(String s[])<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { movball b=new movball();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> b.setSize(new Dimension(1000,600));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> b.setTitle("Running Ball");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> b.setVisible(true);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
mwa extends WindowAdapter<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
movball a;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public mwa(movball f)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { a=f;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public void windowClosing(WindowEvent e)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { a.flag=true;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> a.t=null;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.exit(0);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1EiJCXbawxrWAXTpK08GtnzltSdInJMp8nIiWATxvsf5YxwybLS4pI1O-pGvtQdwLXBMUs2Wxi0MGOanAudLvbr4zVMV9CjCMRtOZNoudurMGbD9dPzz6geGV3TxzAuggGKpz1rKkXcmX/s1600/mvngball.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="216" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1EiJCXbawxrWAXTpK08GtnzltSdInJMp8nIiWATxvsf5YxwybLS4pI1O-pGvtQdwLXBMUs2Wxi0MGOanAudLvbr4zVMV9CjCMRtOZNoudurMGbD9dPzz6geGV3TxzAuggGKpz1rKkXcmX/s320/mvngball.jpg" width="320" /></a></div></td></tr></table>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>
Unknownnoreply@blogger.com76tag:blogger.com,1999:blog-3099703975511476599.post-53343093322669362282012-10-21T04:47:00.001-07:002012-10-21T21:35:40.229-07:00Java program to create user defined exception handling<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
myException extends Exception<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
myException()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { System.out.println("Error:Password too
short");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> myException(int n)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { System.out.println("Error:Only adults
can join");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
user_exception<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
public static void main(String s[])throws IOException,myException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> try<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { System.out.print("Enter user name :
");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> String n=br.readLine();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.print("Enter your
password : ");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> String m=br.readLine();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> if(m.length() <6)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> throw new myException();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.print("Enter your age :
");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int o=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> if(o<18)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> throw new myException(o);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> catch(Exception e)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">} </span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZjT9cmEBnnkXaVmZ08kf4XeF90uDjFkZyZMc5Hm8InDWeV1AL25i6a9KOZ5y3fiwg2ND8gri5qzeKLOJHSNDrob5cFWDnYiV5b0Wh2ZKonOkqFST4QuwwJpa6V3mAb0pT1zYPF8rilW3X/s1600/usrexcptn.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="170" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZjT9cmEBnnkXaVmZ08kf4XeF90uDjFkZyZMc5Hm8InDWeV1AL25i6a9KOZ5y3fiwg2ND8gri5qzeKLOJHSNDrob5cFWDnYiV5b0Wh2ZKonOkqFST4QuwwJpa6V3mAb0pT1zYPF8rilW3X/s320/usrexcptn.jpg" width="320" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
</div>Unknownnoreply@blogger.com57tag:blogger.com,1999:blog-3099703975511476599.post-223636035843634812012-10-21T04:45:00.000-07:002012-10-21T21:37:37.045-07:00Java program to illustrate swing concept<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.awt.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
java.awt.event.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
javax.swing.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
class swing extends JFrame implements ActionListener,ItemListener<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{JComboBox
combo=new JComboBox();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> JButton btnExit=new
JButton("Exit");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Container cp=getContentPane();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Color c=cp.getBackground();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public swing()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> setLayout(null);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> combo.addItem("Reset to Default
Color");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> combo.addItem("Set background
color to red");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> combo.addItem("Set background
color to green");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> combo.addItem("Set background
color to blue");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> cp.add(combo);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> cp.add(btnExit);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> btnExit.setBounds(85,120,70,30);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> combo.setBounds(20,10,200,30);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> combo.addItemListener(this);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> btnExit.addActionListener(this);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
void itemStateChanged(ItemEvent e)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { String
s=(String)e.getItem();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> if(s.compareTo("Reset to
Default Color")==0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> cp.setBackground(c);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> if(s.compareTo("Set background
color to red")==0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> cp.setBackground(Color.red);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> if(s.compareTo("Set background
color to green")==0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> cp.setBackground(Color.green);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> if(s.compareTo("Set background
color to blue")==0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> cp.setBackground(Color.blue);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
void actionPerformed(ActionEvent a)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { String
s=a.getActionCommand();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> if(s.equals("Exit"))<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.exit(0);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
static void main(String[]args)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> swing cd=new swing();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> cd.setSize(new Dimension(250,200));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> cd.setTitle("A swing
application");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> cd.setVisible(true);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif5NwqLpSck-UjVS0FyyYqhL_hzBBzoT9ImngAgeIfwOiO-pRnxts537cIfCC34BYDjkeTo50-7jxBUGqugRYhnZihphxFQ3FEDAQeY2aJaLMPbY6-FRD7kS5Oo7PGeEiZg4SUqnhJDB_q/s1600/swng.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif5NwqLpSck-UjVS0FyyYqhL_hzBBzoT9ImngAgeIfwOiO-pRnxts537cIfCC34BYDjkeTo50-7jxBUGqugRYhnZihphxFQ3FEDAQeY2aJaLMPbY6-FRD7kS5Oo7PGeEiZg4SUqnhJDB_q/s1600/swng.jpg" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>
Unknownnoreply@blogger.com33tag:blogger.com,1999:blog-3099703975511476599.post-88923018162818562972012-10-21T04:41:00.004-07:002012-10-21T21:38:48.020-07:00Java program to create student registration form<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.awt.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
java.applet.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
java.awt.event.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
class student extends Frame implements ActionListener<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{String
msg;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Button b1=new Button("save");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Label l11=new Label("Student
details",Label.CENTER);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Label l1=new
Label("Name:",Label.LEFT);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Label l2=new
Label("age:",Label.LEFT);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Label l3=new Label("Sex(M/F):",Label.LEFT);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Label l4=new
Label("Address:",Label.LEFT);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Label l5=new
Label("Course:",Label.LEFT);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Label l6=new
Label("Semester:",Label.LEFT);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Label l7=new Label("",Label.RIGHT);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> TextField t1=new TextField();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Choice c1=new Choice();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> CheckboxGroup cbg=new CheckboxGroup();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Checkbox ck1=new
Checkbox("Male",false,cbg);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Checkbox ck2=new
Checkbox("Female",false,cbg);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> TextArea t2=new
TextArea("",180,90,TextArea.SCROLLBARS_VERTICAL_ONLY);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Choice course=new Choice();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Choice sem=new Choice();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Choice age=new Choice();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
student()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {addWindowListener(new myWindowAdapter());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> setBackground(Color.cyan);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> setForeground(Color.black);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> setLayout(null);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(l11);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(l1);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(l2);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(l3);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(l4);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(l5);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(l6);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(l7);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(t1);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(t2);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(ck1);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(ck2);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(course);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(sem);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(age);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(b1);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> b1.addActionListener(this);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(b1);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> course.add("BSc c.s");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> course.add("BSc
maths");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> course.add("BSc
physics");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> course.add("BA
English");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> course.add("BCOM");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> sem.add("1");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> sem.add("2");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> sem.add("3");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> sem.add("4");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> sem.add("5");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> sem.add("6");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> age.add("17");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> age.add("18");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> age.add("19");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> age.add("20");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> age.add("21");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l1.setBounds(25,65,90,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l2.setBounds(25,90,90,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l3.setBounds(25,120,90,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l4.setBounds(25,185,90,20); <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l5.setBounds(25,260,90,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l6.setBounds(25,290,90,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l7.setBounds(25,260,90,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l11.setBounds(10,40,280,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> t1.setBounds(120,65,170,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> t2.setBounds(120,185,170,60);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> ck1.setBounds(120,120,50,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> ck2.setBounds(170,120,60,20); <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> course.setBounds(120,260,100,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> sem.setBounds(120,290,50,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> age.setBounds(120,90,50,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> b1.setBounds(120,350,50,30);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
void paint(Graphics g)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{g.drawString(msg,200,450);}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
void actionPerformed(ActionEvent ae)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{if(ae.getActionCommand().equals("save"))<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {msg="Student details saved!";<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> setForeground(Color.red); }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
static void main(String g[])<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{student
stu=new student();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> stu.setSize(new Dimension(500,500));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> stu.setTitle("student
registration");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> stu.setVisible(true);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> class myWindowAdapter extends WindowAdapter<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{public
void windowClosing(WindowEvent we)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.exit(0);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTQTh2AB0_IO6i6TRxMwXcB0aQtPyOkOQkUfk0Ho1Mma6Ijovax2xQ9U9iutU-pF2xGbwZv-FPy8GJVHEf8Ce9UyXGb6jPVnfo2cOBWcSlPtzeVbPsqmjXXa3mDqJpUUucfERbIAMc9Yn4/s1600/stdntreg+copy.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTQTh2AB0_IO6i6TRxMwXcB0aQtPyOkOQkUfk0Ho1Mma6Ijovax2xQ9U9iutU-pF2xGbwZv-FPy8GJVHEf8Ce9UyXGb6jPVnfo2cOBWcSlPtzeVbPsqmjXXa3mDqJpUUucfERbIAMc9Yn4/s320/stdntreg+copy.jpg" width="319" /></a></td></tr></table></div>
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>
Unknownnoreply@blogger.com363tag:blogger.com,1999:blog-3099703975511476599.post-72766561101287681502012-10-21T04:39:00.001-07:002012-10-21T21:40:08.347-07:00Java program to implement single inheritance<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-font-weight: bold; mso-font-kerning: 0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> class
employee<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> { <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> private
String empname;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> private int
empcode; <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> void
read(String s,int p) <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> empname= s;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> empcode=p;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> void
display()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> System.<i>out</i>.println("The
employee name is :" +empname);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> System.<i>out</i>.println("The
employee code is :"+empcode);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> class
labourer extends employee<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> { private
String labourtype;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> private
int laboursalary;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> void
read1()throws IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> BufferedReader br= new BufferedReader( new InputStreamReader (System.<i>in</i>));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> System.<i>out</i>.println("Enter
the employee name:");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> String a=br.readLine();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> System.<i>out</i>.println("Enter
the employee code :");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> int
p= Integer.<i>parseInt</i>(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> read(a,p);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> System.<i>out</i>.println("Enter
the labourtype :");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> labourtype = br.readLine();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> System.<i>out</i>.println("Enter
the labour salary :");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> laboursalary=Integer.<i>parseInt</i>(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> void
display1()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> { <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> display();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> System.<i>out</i>.println(" The
labour type is : "+ labourtype);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> System.<i>out</i>.println(" The
labour salary is :"+laboursalary);
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-font-weight: bold; mso-font-kerning: 0pt;">class</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> single <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> { public
static void main (String s[])throws
IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> {BufferedReader br = new BufferedReader(new InputStreamReader(System.<i>in</i>));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> System.<i>out</i>.println("Enter
the number of employees");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> int n = Integer.<i>parseInt</i>(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> labourer
l[]= new labourer[n];<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> for(int i=0; i<n; i++)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> l[i]=
new labourer();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> for(int i=0; i<n; i++)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> l[i]
.read1();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> for(int i=0; i<n; i++)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> l[i].display1();
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhshOR96Z0E-AqoCiItSHKs7KpP0g1FXDUmEwL7kr4X2jwxDQqSppiZgSelRGeOWicilJhTsRPB9iEnqBfzuwYo_5Crx_w6fMxAtZQYk35GtfjjdybYAwsznz4UHDGUYxiG9pfWCLqmsZSl/s1600/singleiher.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="254" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhshOR96Z0E-AqoCiItSHKs7KpP0g1FXDUmEwL7kr4X2jwxDQqSppiZgSelRGeOWicilJhTsRPB9iEnqBfzuwYo_5Crx_w6fMxAtZQYk35GtfjjdybYAwsznz4UHDGUYxiG9pfWCLqmsZSl/s320/singleiher.jpg" width="320" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"><u><br /></u></span></div>
</div>
Unknownnoreply@blogger.com8tag:blogger.com,1999:blog-3099703975511476599.post-7132139275927795452012-10-21T04:36:00.000-07:002012-10-21T21:45:45.030-07:00Java program to animated text or moving text<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-font-weight: bold; mso-font-kerning: 0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> java.applet.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-font-weight: bold; mso-font-kerning: 0pt;">import</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> java.awt.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">/*<applet
code="runtext" width=450 height=400><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"></applet>*/<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-font-weight: bold; mso-font-kerning: 0pt;">public</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> class
runtext extends Applet implements Runnable<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> Thread t;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> int
x,y;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> boolean
stopflag;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> public void init()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
setBackground(Color.<i>black</i>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
setForeground(Color.<i>white</i>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
x=120;y=130;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> public void start()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
stopflag=false;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
t=new Thread(this,"one");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
t.start();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> public void
paint(Graphics g)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
{showStatus("name of college");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
g.drawString("SS College",x,y);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> public void stop()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
stopflag=true;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
t=null;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> public void run()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">
for(; ;)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> try<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> y++;x++;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> repaint();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> Thread.<i>sleep</i>(50);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> if(stopflag) break;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> catch(InterruptedException
e)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> System.<i>out</i>.println(e);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUfxdG4Dpq0uCLkHvbSQT4IFws_2cG39jQLII8THuoEZkitIavtSUmt7Fa7cljgwaG-X3Wjk4fWPzZS6V3yvaIKljNQFOouuVETi3PowoDJTJL9_SvYboDzvtNkc-Joj0am4IUHgbEFugS/s1600/mvngtext.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="263" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUfxdG4Dpq0uCLkHvbSQT4IFws_2cG39jQLII8THuoEZkitIavtSUmt7Fa7cljgwaG-X3Wjk4fWPzZS6V3yvaIKljNQFOouuVETi3PowoDJTJL9_SvYboDzvtNkc-Joj0am4IUHgbEFugS/s320/mvngtext.jpg" width="320" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"><u><br /></u></span></div>
</div>
Unknownnoreply@blogger.com9tag:blogger.com,1999:blog-3099703975511476599.post-64738346394066704862012-10-21T04:30:00.001-07:002012-10-21T21:49:21.142-07:00Java program to illustrate menubar with the help of applet<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.applet.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
java.awt.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> class mymenu extends Frame<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> MenuBar mb;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Menu filemenu,editmenu,viewmenu;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> MenuItem open,newmi,save,cut,copy;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> CheckboxMenuItem toolbar,layer;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
mymenu()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> mb=new
MenuBar();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> setMenuBar(mb);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> filemenu=new
Menu("File");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> editmenu=new
Menu("Edit");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> viewmenu=new
Menu("View");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> open=new MenuItem("Open");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> newmi=new MenuItem("New");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> save=new MenuItem("Save");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> cut=new MenuItem("Cut");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> copy=new MenuItem("Copy");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> toolbar=new
CheckboxMenuItem("Toolbar",true);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> layer=new
CheckboxMenuItem("Layer Window",false);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> filemenu.add(open);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> filemenu.add(newmi);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> filemenu.add(save);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> editmenu.add(cut);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> editmenu.add(copy);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> viewmenu.add(toolbar);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> viewmenu.add(layer);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> mb.add(filemenu);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> mb.add(editmenu);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> mb.add(viewmenu);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
static void main(String s[])<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> mymenu
mn=new mymenu();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> mn.setSize(new Dimension(500,500));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> mn.setTitle("Menu
Bar");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> mn.setVisible(true);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLEHPX2hwFhuZwdIEmXIH7lTOtbiBdGtAvTZRkLZyaNYjnNf1Vy4gjLKhKpS6cOSilDboCG4F6MtQxiCbcuFPB_VrED_9gdbouz2Y2Csc-LfKYkSnTccyxl1bqssnRqfTxEbrkSPi-iD0H/s1600/menubar.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLEHPX2hwFhuZwdIEmXIH7lTOtbiBdGtAvTZRkLZyaNYjnNf1Vy4gjLKhKpS6cOSilDboCG4F6MtQxiCbcuFPB_VrED_9gdbouz2Y2Csc-LfKYkSnTccyxl1bqssnRqfTxEbrkSPi-iD0H/s320/menubar.jpg" width="318" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-3099703975511476599.post-78675004630338032302012-10-21T04:28:00.000-07:002012-10-21T21:50:08.961-07:00Java program to create login form using applet<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.awt.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
java.awt.event.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
java.applet.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
class Loginform extends Frame implements ActionListener<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
Label l1=new Label("user name");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Label l2=new Label("password");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Label l3=new Label(" ");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> TextField t1=new TextField();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> TextField t2=new TextField();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Button b= new Button("Submit");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public Loginform()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { add(l1);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(t1);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(l2);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(t2);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(b);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> add(l3);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l1.setBounds(20,45,70,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> t1.setBounds(180,45,200,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l2.setBounds(20,95,70,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> t2.setBounds(180,95,200,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> b.setBounds(310,145,70,20);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> b.addActionListener(this);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> t2.setEchoChar('*');<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> addWindowListener(new mwa());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public void actionPerformed(ActionEvent e)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { l3.setText("Welcome
"+t1.getText());}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public static void main(String s[])<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { Loginform l=new Loginform();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l.setSize(new Dimension(600,600));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l.setTitle("Login");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> l.setVisible(true);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
mwa extends WindowAdapter<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
public mwa(){}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public void windowClosing(WindowEvent e)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { System.exit(0);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlh8RYgADpsD4CPMJQCmfT6_NymotlRjwEHAkDK2_NrJBcsoaZtxuD-WEqcqq714esdQA77HhxXisxPXeHP1AOmMg_97O8pK67CtuQRUeIdjlDlUy7AqNd-MbxvB0AF_xW02VYtf_O4OmU/s1600/login.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlh8RYgADpsD4CPMJQCmfT6_NymotlRjwEHAkDK2_NrJBcsoaZtxuD-WEqcqq714esdQA77HhxXisxPXeHP1AOmMg_97O8pK67CtuQRUeIdjlDlUy7AqNd-MbxvB0AF_xW02VYtf_O4OmU/s320/login.jpg" width="320" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>Unknownnoreply@blogger.com214tag:blogger.com,1999:blog-3099703975511476599.post-32255161634103179892012-10-21T04:25:00.001-07:002012-10-21T21:50:52.484-07:00Java program to print fibonacci series upto a given number<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-font-weight: bold; mso-font-kerning: 0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-font-weight: bold; mso-font-kerning: 0pt;">class</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> Fibonacci<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">{ int next,curr,<span style="background: lightgrey; mso-highlight: lightgrey;">prev</span>,num;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> Fibonacci(int a)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> { next=1;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> curr=1;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> <span style="background: lightgrey; mso-highlight: lightgrey;">prev</span>=0;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> num=a;
} <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> void
calc()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> { while(<span style="background: lightgrey; mso-highlight: lightgrey;">prev</span><=num)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> { System.<i>out</i>.println(<span style="background: lightgrey; mso-highlight: lightgrey;">prev</span>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> <span style="background: lightgrey; mso-highlight: lightgrey;">prev</span>=curr;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> curr=next;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> next=<span style="background: lightgrey; mso-highlight: lightgrey;">prev</span>+curr;
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> public
static void main(String s[])throws
IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> { BufferedReader br=new BufferedReader(new
InputStreamReader(System.<i>in</i>));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> System.<i>out</i>.println("Enter the limit");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> int
a=Integer.<i>parseInt</i>(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> Fibonacci f=new Fibonacci(a);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"> f.calc(); }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGw10VYQtihWtLh4hnZ3AqnAhm0gsWsyfXBufszQaDY8MZEoNYvidsaqN0DQG6_LDTXUD7yNLo_0TZzLgEg8VnkGnZOY7SO6XzjBpEd8MdeEqgCuXQwXijR514fOsVP_VICK8Yk-o3GPHk/s1600/exception.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGw10VYQtihWtLh4hnZ3AqnAhm0gsWsyfXBufszQaDY8MZEoNYvidsaqN0DQG6_LDTXUD7yNLo_0TZzLgEg8VnkGnZOY7SO6XzjBpEd8MdeEqgCuXQwXijR514fOsVP_VICK8Yk-o3GPHk/s320/exception.jpg" width="320" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-font-kerning: 0pt;"><u><br /></u></span></div>
<br /></div>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-3099703975511476599.post-8998766070753475202012-10-21T04:21:00.000-07:002012-10-21T21:57:14.496-07:00Java program to illustrate exception handling<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.lang.ArithmeticException;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
java.util.*;
//import util package<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public
class ExceptionDemo<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ public static void main(String s[])<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {
Scanner b1=new Scanner(System.in);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> try<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {
System.out.println("Enter the Divident?");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> double a=b1.nextDouble();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter the
Divisor?");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> double b=b1.nextDouble();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> if(b==0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> //Throwing an Exception using throw<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> throw new
ArithmeticException("Division by zero!");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> double res=a/b;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Result
of"+a+"/"+b+"is"+res); <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> //Handles input mismatch exception caused by<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> //entering a non-integer value at th point<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> catch(InputMismatchException e)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {
System.out.println("Error:"+e);}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">//Handles
the divide-by-zero ArithmeticException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> catch(ArithmeticException ae)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {
System.out.println("Error:"+ae);}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGw10VYQtihWtLh4hnZ3AqnAhm0gsWsyfXBufszQaDY8MZEoNYvidsaqN0DQG6_LDTXUD7yNLo_0TZzLgEg8VnkGnZOY7SO6XzjBpEd8MdeEqgCuXQwXijR514fOsVP_VICK8Yk-o3GPHk/s1600/exception.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGw10VYQtihWtLh4hnZ3AqnAhm0gsWsyfXBufszQaDY8MZEoNYvidsaqN0DQG6_LDTXUD7yNLo_0TZzLgEg8VnkGnZOY7SO6XzjBpEd8MdeEqgCuXQwXijR514fOsVP_VICK8Yk-o3GPHk/s1600/exception.jpg" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3099703975511476599.post-6088147160325971522012-10-21T04:15:00.001-07:002012-10-21T21:57:47.818-07:00Java program to find distance between two points in a plane<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
distance<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int x,y,dist;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> distance()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { x=0;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> y=0;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void calc(distance c,distance d)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int
xd=c.x-d.x;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int xs=xd*xd;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int yd=c.y-d.y;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int ys=yd*yd;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int sum=xs+ys;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> double dist=Math.sqrt(sum);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("The distance is
"+dist);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void read()throws IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter the x
coordinate");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> x=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter the y
coordinate");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> y=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("The entered point
is "+"("+x+","+y+")");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public static void main(String s[])throws
IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> distance c=new distance();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> distance d=new distance();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("First
point");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> c.read();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Second
point");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> d.read();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> d.calc(c,d);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHDpHmwjQs6G9n8CgpSjIpWhyphenhyphenIHcouuWnmdpNsM7cccjXi4moZpcnIpxRAgyrh0hBU77fZ2OZ6SJjzO-7xgQ_IzxDr4h6rGSkm5TPiTaB_EbrO3H-XNpfhd_3k-X_58AlkGRsHJe8DDs4D/s1600/dst2pnts.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="222" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHDpHmwjQs6G9n8CgpSjIpWhyphenhyphenIHcouuWnmdpNsM7cccjXi4moZpcnIpxRAgyrh0hBU77fZ2OZ6SJjzO-7xgQ_IzxDr4h6rGSkm5TPiTaB_EbrO3H-XNpfhd_3k-X_58AlkGRsHJe8DDs4D/s320/dst2pnts.jpg" width="320" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3099703975511476599.post-51648193384573300272012-10-21T04:12:00.001-07:002012-10-21T21:58:18.871-07:00Java program to perform complex number addition<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
complex<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int
r,i;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> complex()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> r =0;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
i=0;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void sum(complex c,complex d)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">complex
a=new complex();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">a.r=c.r+d.r;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">a.i=c.i+d.i;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("The sum is
"+a.r+"+"+a.i+"i");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void read()throws IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("\nEnter the real
part");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> r=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("\nEnter the
imaginary part");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> i=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("\nYou have entered :
"+r+"+"+i+"i");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public static void main(String s[])throws
IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> complex c=new complex();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> complex d=new complex();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("First
number");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> c.read();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("\nSecond
number");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> d.read();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> d.sum(c,d);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu3BILjZNG4l7O_uRX2GzJ-WI2qoxIm_qGJrlQqhMSiYMrHwL0hOD3io5wZ6wrIzUIidFzYw18bH1k2z75yerhFasZZF4DA0_380IGjCx2dy_DTFhlK1b4LoqzvydMpcB41sMQqwKHMxzm/s1600/cmplx.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="251" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu3BILjZNG4l7O_uRX2GzJ-WI2qoxIm_qGJrlQqhMSiYMrHwL0hOD3io5wZ6wrIzUIidFzYw18bH1k2z75yerhFasZZF4DA0_380IGjCx2dy_DTFhlK1b4LoqzvydMpcB41sMQqwKHMxzm/s320/cmplx.jpg" width="320" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3099703975511476599.post-62773517369952949592012-10-21T04:10:00.000-07:002012-10-21T21:58:47.500-07:00Java program to perform string sorting<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
stringsort<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { String p[];int i;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> stringsort(int q)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> p=new String[q];<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void read() throws IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {BufferedReader br= new BufferedReader(new
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> for(int i= 0; i<p.length; i++)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {System.out.println("Enter the
"+(i+1)+"th element"); <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> p[i]=br.readLine();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void sort()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { for (int i=0;i<p.length-1;i++)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> for(int j=i+1;j<p.length;j++)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> if (p[i].compareTo(p[j])>0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { String temp= p[i];<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> p[i]=p[j];<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> p[j]= temp;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void disp()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {System.out.println("The sorted string
is:");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> for (int i=0;i<p.length;i++) <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println(p[i]);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public static void main(String s[]) throws
IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {BufferedReader b= new BufferedReader(new
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("How many
names?") ;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int m =
Integer.parseInt(b.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> stringsort k= new stringsort(m);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> k.read();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> k.sort();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> k.disp();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-8kfMx4fChNZR00KJ9kYJMVJlUY9ONI3zspJ3uI5UqO_8EzHsJgIGbRQAFF91EAVvG18lOzmpXUkxOSeaqUSGokuymEivqS4A2PmBQKr-jnCM5AuA__1eTiEV_blZwJBDglj7_xFhD6gF/s1600/strngsort.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="166" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-8kfMx4fChNZR00KJ9kYJMVJlUY9ONI3zspJ3uI5UqO_8EzHsJgIGbRQAFF91EAVvG18lOzmpXUkxOSeaqUSGokuymEivqS4A2PmBQKr-jnCM5AuA__1eTiEV_blZwJBDglj7_xFhD6gF/s320/strngsort.jpg" width="320" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3099703975511476599.post-24743029931533421212012-10-21T04:07:00.000-07:002012-10-21T22:00:05.923-07:00Java program to illustrate the concept of abstract class<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>abstract
class figure<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{float
l,b;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> figure(float x,float y)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {l=x;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> b=y; }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> abstract float area();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
rectangle extends figure<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
rectangle(float a,float b)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
super(a,b); }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">float
area()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
return(l*b); }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
triangle extends figure<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{triangle(float
a,float b)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {
super(a,b); }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> float area()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {return(l*b/2); }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
figurearea<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
public static void main(String a[])<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {
rectangle r=new rectangle(2.5f,2.5f);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> triangle t=new triangle(1f,2.0f);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> figure f=r;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("area of
rectangle="+f.area());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> f=t;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("area of
triangle="+f.area()); }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjfoFOR1iE6x_Xtc_8S-GjLQfKQ5r9FEZ6cZZLKwWF4POYNNYBpiMn4VLxTG_4fuvd-k-Jw2TYFQv5oRgBM0vw0jpYys4CemugUd600ea96VO2pdV6M4i77-UbLxBKWni3pKHY3fyd3I7Z/s1600/abstrct.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="161" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjfoFOR1iE6x_Xtc_8S-GjLQfKQ5r9FEZ6cZZLKwWF4POYNNYBpiMn4VLxTG_4fuvd-k-Jw2TYFQv5oRgBM0vw0jpYys4CemugUd600ea96VO2pdV6M4i77-UbLxBKWni3pKHY3fyd3I7Z/s320/abstrct.jpg" width="320" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3099703975511476599.post-52910330397731566822012-10-21T04:05:00.000-07:002012-10-21T22:00:44.895-07:00Java program to implement multiple inheritance<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.io.*; <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">interface bookinfo<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ public
void getbookdata()throws IOException;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public
void putbookdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">interface basicinfo<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ public
void getbasicdata()throws IOException;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public
void putbasicdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">interface otherinfo<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ public
void getotherdata()throws IOException;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public
void putotherdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class book implements bookinfo,basicinfo,otherinfo<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ String
Bname,Bauthor, Blanguage,Bpublisher;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int Bprice, Bcopies,Byear;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> BufferedReader
br=new BufferedReader(new <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void getbookdata()throws IOException<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ System.out.println("Enter
the Book name:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Bname=br.readLine();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter
the author's name:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Bauthor=br.readLine();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void putbookdata()<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{
System.out.print(Bname+"\t"+Bauthor+"\t");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void getbasicdata()throws IOException<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ System.out.println("Enter
the language:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Blanguage=br.readLine();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter
the published year:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Byear=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter
the price");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Bprice=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void putbasicdata()<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ System.out.print(Blanguage+"\t\t"+Byear+"\t"+Bprice+"\t");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void getotherdata()throws IOException<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ System.out.println("Enter
the number of copies:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Bcopies=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter
the publisher:");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> Bpublisher=br.readLine();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public void putotherdata()<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ System.out.print(Bcopies+"\t"+Bpublisher+"\t\t");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class interfaceEg<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">public static void main(String s[])throws
IOException<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
book it[];<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> BufferedReader br=new BufferedReader(new <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("How much
entries..?");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int k=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
it=new book[k];<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> for(int i=0;i<k;i++)<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { it[i]=new book();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
for(int i=0;i<k;i++)<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
int j=i+1;<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("ENTER DETAILS OF
THE BOOK : "+j);<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].getbookdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].getbasicdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].getotherdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
System.out.println("\n\n***********-----------------Book <o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
details-----------------************\n");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
System.out.println("Book\tAuthor\tLanguage\tYear\tPrice\tCopies<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
\tPublisher");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
System.out.println("............................................................................");<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
for(int i=0;i<k;i++)<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].putbookdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].putbasicdata();<o:p></o:p></span></div>
<div class="MsoNoSpacing">
<span lang="EN-US" style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> it[i].putotherdata();<o:p></o:p></span></div>
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 107%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
}</span><br />
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 107%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> }</span><br />
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 107%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> }</span><br />
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 107%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><u>Output</u></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKD_UpuURu_Fimt0LW7Fgy_95nIGQJIjn-XBQLjIn3Gxt_FaqJTlLpSUEvuby9F-iolmbqCQOZxDWSA6TEPVcJ9EvwVS-EqKgb_NzGYN6ul9u6y4Bv8amqB6I3DIDKScyPFSiijfO4Onns/s1600/mlplinhrt.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKD_UpuURu_Fimt0LW7Fgy_95nIGQJIjn-XBQLjIn3Gxt_FaqJTlLpSUEvuby9F-iolmbqCQOZxDWSA6TEPVcJ9EvwVS-EqKgb_NzGYN6ul9u6y4Bv8amqB6I3DIDKScyPFSiijfO4Onns/s320/mlplinhrt.jpg" width="320" /></a></td></tr></table></div>
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 107%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3099703975511476599.post-54361536734477610882012-10-21T04:03:00.000-07:002012-10-21T22:05:42.695-07:00Java program to find largest among 3 numbers<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><table border="2" bgcolor="#eae9f5"><tr><td>import
java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
largest<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int a,b,c,large;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void read()throws IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> BufferedReader br=new
BufferedReader( new InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter
3 numbers");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> a=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> b=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> c=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void check()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { if(a>b & a>c)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> large=a;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> else if(b>c)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> large=b;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> else <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> large=c;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("The largest number
is "+large);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public static void main(String s[])throws
IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { largest
n=new largest();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> n.read();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> n.check();
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">} <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaNJns-skiTPwaKCs6rLm37_m04gBEbXh-rFvEXvGO0-n73Q-P4Vwphyphenhyphen1oKNIKyoD_Q6Fn8elZV2eXJ4z4qBJkASCKWvY8yjdQOIvbK2TeUxvvCQ5xrlsvTSzgww1w5iO8k8x7TMC63epU/s1600/large3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="141" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaNJns-skiTPwaKCs6rLm37_m04gBEbXh-rFvEXvGO0-n73Q-P4Vwphyphenhyphen1oKNIKyoD_Q6Fn8elZV2eXJ4z4qBJkASCKWvY8yjdQOIvbK2TeUxvvCQ5xrlsvTSzgww1w5iO8k8x7TMC63epU/s320/large3.jpg" width="320" /></a></td></tr></table></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3099703975511476599.post-35810321733499189362012-10-21T03:59:00.000-07:002012-10-21T03:59:45.632-07:00Java program to illustrate method overloading<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
area<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int l,b,r;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> float s;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void sample(int l,int b)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> s=b*l;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("area of
rectangle="+s);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void sample(int r)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> s=r*r;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("area of
square="+s);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public static void main(String s[])<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> area a=new area();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> a.sample(5,3);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> a.sample(6);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVE-5k5pvf2ghyw-8yNwm_7TmWEL9rNLkB7Pyrz22wJU0j-LljeHRWNLr-LISCOKaSkf16OXu0v1ZPYOiEwRCPb1s7KZ0WxUL9e6utWoDhgf1DSAN5lvfAcp_5F1JdP9ijB6bHssIdb2dR/s1600/mthd.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="162" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVE-5k5pvf2ghyw-8yNwm_7TmWEL9rNLkB7Pyrz22wJU0j-LljeHRWNLr-LISCOKaSkf16OXu0v1ZPYOiEwRCPb1s7KZ0WxUL9e6utWoDhgf1DSAN5lvfAcp_5F1JdP9ijB6bHssIdb2dR/s320/mthd.jpg" width="320" /></a></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3099703975511476599.post-27490445234161807022012-10-21T03:56:00.001-07:002012-10-21T03:57:08.291-07:00Java program to find reverse of a number<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
reverse<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{ <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int num,temp,p;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> reverse(int a)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {num=a;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> temp=num;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> p=0;}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void findreverse()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { while(temp>0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {p=p*10+temp%10;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> temp/=10;}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Reverse of
"+num+" is "+p);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public static void main(String s[])throws
IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter the number
to reverse");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int n=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> reverse r=new reverse(n);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> r.findreverse();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u>Output</u></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnwmr2udMyC503d8OKNr3rpT3zIVDmt5pRvtmHy3B46hI0lCwIaE-7UbXDHgvNC9Ml4IMjeAvL5d0um7k1MwOU1QYK0lZ3RPpur7r_3X77Se4-yENr93k_BpTNq_vPCmkOLQ39WthzFjeJ/s1600/rev.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="140" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnwmr2udMyC503d8OKNr3rpT3zIVDmt5pRvtmHy3B46hI0lCwIaE-7UbXDHgvNC9Ml4IMjeAvL5d0um7k1MwOU1QYK0lZ3RPpur7r_3X77Se4-yENr93k_BpTNq_vPCmkOLQ39WthzFjeJ/s320/rev.jpg" width="320" /></a></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><u><br /></u></span></div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3099703975511476599.post-21331733631509121272012-10-21T03:54:00.000-07:002012-10-21T04:00:03.900-07:00Java program to print amstrong numbers upto given number<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">import
java.io.*;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">class
strangenum<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{int
num,temp,d,s;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> strangenum(int a)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { num=a;}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> void gen_strange()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { System.out.println("strnge numbers
are");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> for(int i=0;i<=num;i++)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {temp=i;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> s=0;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> while(temp>0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { d=temp%10;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> s+=d*d*d;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> temp/=10; }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> if(s==i)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println(i); }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> public static void main(String s[])throws
IOException<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> { BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> System.out.println("Enter the
limit");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> int a=Integer.parseInt(br.readLine());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> strangenum st=new strangenum(a);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> st.gen_strange();}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3099703975511476599.post-91782979098519277652012-10-17T09:04:00.001-07:002012-10-17T09:05:36.160-07:00Program to perform the addition of complex numbers<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5FBFb7ihx8U_-LjRjUB-cN33mvP7tkc7n0dZgOidzF0rtGE6IfuQ-iibLULhijJ3B6c5TjleQH3ETFhc5oTmUFr5Dx5RPofQIQW-woXN2lvgY08HQuu0fGEy8putnpSQ7XSMsEELKbMzJ/s1600/Picture1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5FBFb7ihx8U_-LjRjUB-cN33mvP7tkc7n0dZgOidzF0rtGE6IfuQ-iibLULhijJ3B6c5TjleQH3ETFhc5oTmUFr5Dx5RPofQIQW-woXN2lvgY08HQuu0fGEy8putnpSQ7XSMsEELKbMzJ/s1600/Picture1.jpg" height="297" width="320" /></a></div>
<br />
#include<iostream.h><br />
#include<conio.h><br />
class comp<br />
{ private:<br />
int r,i;<br />
public:<br />
void get();<br />
void disp(comp,comp);<br />
comp();<br />
};<br />
comp::comp()<br />
{<br />
r=0;<br />
i=0;<br />
}<br />
void comp::get()<br />
<br />
{<br />
cout<<"\n\nEnter a complex number :-";<br />
cout<<"\n\n\nEnter real part :\t";<br />
cin>>r;<br />
cout<<"\n\n\nEnter imaginary part:\t";<br />
cin>>i;<br />
cout<<"\n\n\nComlex number you entered :\t"<<r<<"+"<<i<<"i";<br />
}<br />
void comp::disp(comp a1,comp a2)<br />
{<br />
comp c;<br />
c.r=a1.r+a2.r;<br />
<br />
c.i=a1.i+a2.i;<br />
cout<<"\n\n\n---------------------------------\n\n\nSum of the given complex numbers ="<<c.r<<"+"<<c.i<<"i";<br />
}<br />
void main()<br />
{ clrscr();<br />
comp a1,a2;<br />
a1.get();<br />
a2.get();<br />
a1.disp(a1,a2);<br />
getch();<br />
}<br />
<br />
<br />
<b>Sample input and output</b><br />
<br />
Enter a complex number<br />
Enter real part:2<br />
Enter imaginary part:3<br />
Enter a complex number<br />
Enter real part:1<br />
Enter imaginary part:3<br />
Sum of the given complex numbers =3+6i<br />
<br />
<br />
<br />
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3099703975511476599.post-79756089532246722182012-08-16T18:13:00.001-07:002012-08-16T18:13:04.924-07:00C++ program to perform array operations<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
//Program to create array,display array,search for an element and delete<br />
#include<iostream.h><br />
#include<conio.h><br />
#include<process.h><br />
class array<br />
{<br />
int a[100];<br />
int terms;<br />
public:<br />
array();<br />
void create();<br />
void display();<br />
void search();<br />
void delete();<br />
};<br />
array::array()<br />
{terms=0;}<br />
//create an array<br />
void array::create()<br />
{<br />
int i;<br />
cout<<"How many elements in the array:";<br />
cin>>terms;<br />
if((terms>100)||(terms<0))<br />
{<br />
cout<<"Sorry! the size does not support";<br />
getch();<br />
return;<br />
}<br />
{cout<<"enter the element";<br />
for(i=0;i<terms;++i)<br />
cin>>a[i];<br />
}}<br />
//Display the content of the array<br />
void array::display()<br />
{int i;<br />
for(i=0;i<terms;i++)<br />
cout<<a[i]<<" ";<br />
}<br />
//search<br />
void array::search()<br />
{int m;<br />
cout<<"enter the element to search:";<br />
cin>>m;<br />
for(int i=0;i<terms;i++)<br />
if(a[i]==m)<br />
{cout<<m<<" is found in "<<i+1<<" position";break;}<br />
else<br />
if(i==terms)<br />
cout<<"not found";<br />
}<br />
//Delete<br />
void array::delete()<br />
{int p;<br />
cout<<"enter the position to delete:";<br />
cin>>p;<br />
if((p>terms)||(p<1))<br />
cout<<"Position invalid!";<br />
else<br />
{terms--;<br />
for(int i=0;i<terms;i++)<br />
a[i]=a[i+1];<br />
}}<br />
<br />
void main()<br />
{ clrscr();<br />
array ar;<br />
abcd:<br />
cout<<"\n\nARRAY\n";<br />
cout<<".........\n";<br />
cout<<" 1.create\n 2.Display \n 3.Search\n 4.Delete \n 5.Exit\n\n";<br />
cout<<"Enter your option...";<br />
<br />
int inp;<br />
cin>>inp;<br />
switch(inp)<br />
{ case 1: ar.create();goto abcd;<br />
case 2: ar.display();goto abcd;<br />
case 3: ar.search();goto abcd;<br />
case 4: ar.delete();goto abcd;<br />
case 5: exit(0);<br />
}<br />
}<br />
</div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3099703975511476599.post-47361093700088692992012-08-12T07:23:00.002-07:002012-08-12T07:23:20.518-07:00Java program to read and print student information<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
import java.io.*;<br />
class student<br />
{<br />
int slno;<br />
String name;<br />
student()<br />
{<br />
name=new String();<br />
slno=0;<br />
}<br />
void get()throws IOException<br />
{<br />
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));<br />
System.out.print("Enter the name of the student: ");<br />
name=br.readLine();<br />
System.out.print("\nEnter the Serial Number: ");<br />
slno=Integer.parseInt(br.readLine());<br />
}<br />
void disp()<br />
{<br />
System.out.println("Serial Number : "+slno+"\nName : "+name);<br />
}<br />
}<br />
class studmark extends student<br />
{<br />
int m1,m2;<br />
studmark()<br />
{<br />
m1=m2=0;<br />
}<br />
void get()throws IOException<br />
{<br />
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));<br />
System.out.println("Enter the mark1: ");<br />
m1=Integer.parseInt(br.readLine());<br />
System.out.println("Enter the mark2: ");<br />
m2=Integer.parseInt(br.readLine());<br />
}<br />
void disp()<br />
{<br />
System.out.println("Mark1 = "+m1+"\nMark2 = "+m2);<br />
}<br />
}<br />
class personal extends studmark<br />
{<br />
int w,age;<br />
personal()<br />
{<br />
w=age=0;<br />
}<br />
void get()throws IOException<br />
{<br />
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));<br />
System.out.println("Enter the Weight : ");<br />
w=Integer.parseInt(br.readLine());<br />
System.out.println("Enter the age : ");<br />
age=Integer.parseInt(br.readLine());<br />
}<br />
void disp()<br />
{<br />
System.out.println("Weight = "+w+"\nAge = "+age);<br />
}<br />
}<br />
class studinheritance<br />
{<br />
public static void main(String[] args)throws IOException<br />
{<br />
student x;<br />
student y= new student();<br />
x=y;<br />
x.get();<br />
x.disp();<br />
studmark i;<br />
x=i;<br />
x.get();<br />
x.disp();<br />
personal p;<br />
x=p;<br />
x.get();<br />
x.disp();<br />
}<br />
}<br />
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3099703975511476599.post-82225748420032883442012-08-12T07:21:00.002-07:002012-08-12T07:23:30.005-07:00Java program to perform String sorting<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
import java.io.*;<br />
class stringsort<br />
{<br />
String s[];<br />
int n;<br />
stringsort(int q)<br />
{<br />
s=new String[q];<br />
n=q;<br />
}<br />
void sortstring()throws IOException<br />
{<br />
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));<br />
System.out.println("Enter The names: ");<br />
for(int i=0;i<s.length;i++){<br />
System.out.print("name: "+(i+1));<br />
s[i]=br.readLine();}<br />
}<br />
void sort()<br />
{<br />
for(int i=0;i<s.length-1;i++)<br />
for(int j=i+1;j<s.length;j++)<br />
{<br />
if(s[i].compareTo(s[j])>0)<br />
{<br />
String temp=s[i];<br />
s[i]=s[j];<br />
s[j]=temp;<br />
}<br />
}<br />
System.out.println("\nThe sorted array is: ");<br />
for(int i=0;i<s.length;i++)<br />
System.out.println(s[i]);<br />
}<br />
public static void main(String[] args)throws IOException<br />
{<br />
BufferedReader b= new BufferedReader(new InputStreamReader(System.in));<br />
System.out.println("\nEnter no of names : " );<br />
int x=Integer.parseInt(b.readLine());<br />
stringsort s=new stringsort(x);<br />
s.sortstring();<br />
s.sort();<br />
}<br />
}</div>Unknownnoreply@blogger.com0