SlideShare ist ein Scribd-Unternehmen logo
1 von 23
INFORMATICSPRACTICES

PRACTICAL

SUBMITTEDBY :
CSAISATHVICK
ROLL NO :

46
JAVA PROGRAMMING
Q1.Design a java program to print the table of the entered number?
Ans.
Preview-

Source Code-

Code for Table
private void jButton1ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
int x= Integer.parseInt(AT.getText());
inty,z=0;
for(y=1;y<=10;++y) {
z=y*x;
RT.append(z+"n");

}}
Code for Clear
private void clearActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
AT.setText(" ");
RT.setText(" "); }

Q2.Design a java program to print the Fibonacci series of the entered number?
Ans.
Preview-

Source Code-

Code for Fibonacci
private void jButton2ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
int s1=0,s2=1,sum,n;
n=Integer.parseInt(AT.getText());
if(n==0)
RT.append(0+"n");
else
if(n==1)
RT.append(0+"n"+1+"n");
else {
RT.append(0+"n"+1+"n");
RT.append("");
for(inti=2; i<=n; i++) {
sum=s1+s2;
RT.append(sum+"n");
RT.append(" ");
s1=s2;
s2=sum;

} } }

Code for Clear
private void clearActionPerformed (java.awt.event.ActionEventevt) {
// TODO add your handling code here:
AT.setText("");
RT.setText("");
}
Q3.Design a java program to display the scored goal details and match result?
Ans.
Preview-

Source Code-

Code for Scored By A
private void GOAActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
intga= Integer.parseInt(tAGoals.getText());
ga=ga+1;
tAGoals.setText(""+ga); }

Code for Scored By B
private void GOBActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
intgb= Integer.parseInt(tBGoals.getText());
gb=gb+1;
tBGoals.setText(""+gb); }
Code for Declare Match
private void DCActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
intga=Integer.parseInt(tAGoals.getText());
intgb=Integer.parseInt(tBGoals.getText());
String res=(ga>gb?"Team A wins":(ga<gb)?"Team B wins":"Draw");
result.setText(res);

}

Code for Clear
private void CLEARActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
result.setText(" ");
tBGoals.setText("0");
tAGoals.setText("0");

}

Q4. Design a java program to add the Digits in input area?
Ans.
Preview-
Code of main methodintaddDigits(int n){int s=0;
int dig;
while(n>0){
dig=n%10;
s=s+dig;
n=n/10;
}return s;
}

Code for Compt……….. Buttonintnum=Integer.parseInt(input.getText());
int sum=addDigits(num);
out.setText("Sum of its digits is "+sum);
Q5. Design a java program to change background colour of different input
controls ?
Ans.
Preview-

Code for the jList (Event –ListSelection-valueChanged)private void ColValueChanged(javax.swing.event.ListSelectionEventevt) {
// TODO add your handling code here:
inti;
Color x=Color.WHITE;
i=Col.getSelectedIndex();
switch(i){
case 0: x=Color.RED;
break;
case 1: x=Color.BLUE;
break;
case 2: x=Color.GREEN;
break;
case 3: x=Color.MAGENTA;
break;
case 4: x=Color.CYAN;
break;
case 5: x=Color.YELLOW;
break;
case 6: x=Color.GRAY;
break;
}
if(LBL1.isSelected())
Lb.setBackground(x);
else
Lb.setBackground(Color.WHITE);
if(LBL2.isSelected())
Btn.setBackground(x);
else
Btn.setBackground(Color.WHITE);
if(LBL3.isSelected())
TF.setBackground(x);
else
TF.setBackground(Color.WHITE);
Q6. Design a java program to select the character from the list as given in
textfield?
Ans.
Preview-

Code of Select in List Buttonprivate void oKActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
List.setSelectedValue(ENTER.getText(), true);
Q7.Design a java program to print the numbers in between the given input?
Ans.

Code of Count Buttonint a=Integer.parseInt(IN1.getText());
int b=Integer.parseInt(IN2.getText());
if(a>b){
for(;b<=a;b++)
{OUT.append(b+" ");}
}
else{
for(;a<=b;a++)
{ OUT.append(a+" ");}
}
Q8. Design a java program to check a string is palindrome or not?
Ans.

Code of Perform Palindrome Test ButtonString str=In.getText();
showPalindrome(str);

Main method Codepublic void showPalindrome(String s){
StringBuffer out=new StringBuffer(s);
if(isPalindrome(s))
s=s+": is a palindrome!";
else if(isPalindrome2(s))
s=s+ ": is a palindrome if you ignore case";
else
s=s+": is not a palinidrome! ";
Out.setText(s);
}
publicbooleanisPalindrome(String s)
{StringBuffer reversed=(new StringBuffer(s)).reverse();
returns.equalsIgnoreCase(reversed.toString());
}
publicboolean isPalindrome2(String s)
{StringBuffer reversed=(new StringBuffer(s)).reverse();
returns.equalsIgnoreCase(reversed.toString());
}
Q9. Design a java program to reverse a string?
Ans.

Code of Reverse ButtonString a=IN.getText();
String b="";
for(inti=a.length()-1;i>=0;i--){
b=b+a.charAt(i);
}OUT.setText(b);
Q10. Design a java program to find the occurrence of a character?
Ans.

Code of Count ButtonString a=In1.getText();
char b=In2.getText().charAt(0);
int c=0;
for(int d=0;d<a.length();d++){

if(a.charAt(d)==b)
c++;
} Out.setText (""+c);
Q11. Design a java program to find the position of a vowel in a string?
Ans.

Code of OK Button// TODO add your handling code here:
String a=IN.getText();
for(int d=0;d<=a.length();d++){
char c=a.charAt(d);
switch(c){
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
d=d+1;
OUT.append(" "+d+"n");
break;
default: } }

Q12. Design a java program to display a menu of Ice-cream parlour ?
Ans.

Code of Calculate Buttonif(St.isSelected()==true)
{ STP.setText("35");}
else
{STP.setText("0");
STQ.setText("0");}
if(Ch.isSelected()==true)
{CHP.setText("50");}
else
{CHP.setText("0");
CHQ.setText("0");}
if(Va.isSelected()==true)
{VAP.setText("30");}
else
{VAP.setText("0");
VAQ.setText("0");}
int a1,a2,a3,a4,a5,a6,a7,a8,a9,a10;
a1=Integer.parseInt(STP.getText());
a2=Integer.parseInt(CHP.getText());
a3=Integer.parseInt(VAP.getText());
a4=Integer.parseInt(STQ.getText());
a5=Integer.parseInt(CHQ.getText());
a6=Integer.parseInt(VAQ.getText());
a7=a1*a4;
a8=a2*a5;
a9=a3*a6;
STT.setText(""+a7);
CHT.setText(""+a8);
VAT.setText(""+a9);
a10=a7+a8+a9;
OUT.setText(a10+"");

Code of Clear ButtonSt.setSelected(false);
Ch.setSelected(false);
Va.setSelected(false);
STT.setText("");
VAT.setText("");
CHT.setText("");
OUT.setText("");
STQ.setText("");
VAQ.setText("");
CHQ.setText("");
VAP.setText("");
STP.setText("");
CHP.setText("");

Code of Exit ButtonSystem.exit (0);
Q13. Design a class program to display a detail of a book ?
Ans.
Class Methodpublic class book {
String name,author;
int edition;
float price;
public book(){
this.name="";
this.author="";
edition=2000;
price=100.0f;
}
public book(String a,Stringb,intc,float d){
this.name=a;
this.author=b;
edition=c;
price=d;
}
void display(){
System.out.println("Name of the book is "+name);
System.out.println("Author of book is "+author);
System.out.println("Edition:-"+edition);
System.out.println("Price:-"+price);
}

Main Methodbook B1=new book ("The Canterville Ghost”, “Oscar Wilde",2012,55);
B1.display ();

Q14. Design program to display a student record table ?
Ans.

Class Methodvoid process(){
int a=0;
String name="",hname="";
doubleperc=0.0,hperc=0.0;
do{name=JOptionPane.showInputDialog("Enter Student's name:");
perc=Double.parseDouble(JOptionPane.showInputDialog("Enter Percentage Marks:"));
resTa.append(name+"t"+perc+"n");
if(hperc<perc){
hperc=perc;
hname=name;
}
a=JOptionPane.showConfirmDialog(null,"More Student info??");
}
while(a==JOptionPane.YES_OPTION);
if(a==JOptionPane.NO_OPTION){
JOptionPane.showMessageDialog(null,"Highest scorer is "+hname+" with "+hperc+"marks. ");
}
}

Main MethodJOPdialogs j1=new JOPdialogs();
j1.setVisible(true);
j1.process();
j1.setVisible(false);
Q15. Design a class program to print detail of a student?
Ans.
Class Methodpublic class Student{
introllNumber = 0;
String name = "nil";
public Student(intrno,Stringsname){
rollNumber=rno;
name=sname;
}
void display(){
System.out.println("RollNumber ="+rollNumber);
System.out.println("Name ="+name);
}

Main MethodStudentB1=new Student(23,"GOVIND");
B1.display();
}
}

Weitere ähnliche Inhalte

Was ist angesagt?

chemistry investigatory project class 12
chemistry investigatory project class 12chemistry investigatory project class 12
chemistry investigatory project class 12Roshan Bastia
 
Computer Science Investigatory Project Class 12
Computer Science Investigatory Project Class 12Computer Science Investigatory Project Class 12
Computer Science Investigatory Project Class 12Self-employed
 
Computer science project.pdf
Computer science project.pdfComputer science project.pdf
Computer science project.pdfHarshitSachdeva17
 
Chemistry investigatory project for everyone
Chemistry investigatory project for everyoneChemistry investigatory project for everyone
Chemistry investigatory project for everyoneApil Meena
 
content of cold drinks available in the market-chemistry investigatory project
content of cold drinks available in the market-chemistry investigatory projectcontent of cold drinks available in the market-chemistry investigatory project
content of cold drinks available in the market-chemistry investigatory projectSai Sathvick Chirakala
 
C++ COMPUTER SCIENCE PROJECT
C++ COMPUTER SCIENCE PROJECTC++ COMPUTER SCIENCE PROJECT
C++ COMPUTER SCIENCE PROJECTAbhishek Shukla
 
Chemistry project on cold drinks
Chemistry project on cold drinksChemistry project on cold drinks
Chemistry project on cold drinksAditya Sharma
 
cbse 12th chemistry investigatory project
cbse 12th chemistry investigatory project cbse 12th chemistry investigatory project
cbse 12th chemistry investigatory project NIKHIL DWIVEDI
 
IP Project for Class 12th CBSE
IP Project for Class 12th CBSEIP Project for Class 12th CBSE
IP Project for Class 12th CBSESylvester Correya
 
Foaming Capacity of Soap
Foaming Capacity of SoapFoaming Capacity of Soap
Foaming Capacity of SoapSaurav Ranjan
 
CBSE class 12th Chemistry project on antacids for cbse aissce 2017-2018
CBSE class 12th Chemistry project on antacids for cbse aissce 2017-2018CBSE class 12th Chemistry project on antacids for cbse aissce 2017-2018
CBSE class 12th Chemistry project on antacids for cbse aissce 2017-2018Vishvjeet Yadav
 
Chemistryinvestigatory 130128120104-phpapp01 (1)
Chemistryinvestigatory 130128120104-phpapp01 (1)Chemistryinvestigatory 130128120104-phpapp01 (1)
Chemistryinvestigatory 130128120104-phpapp01 (1)enakshi pal
 
STERELISATION OF WATER WITH BLEACHING POWDER
STERELISATION OF WATER WITH BLEACHING POWDER STERELISATION OF WATER WITH BLEACHING POWDER
STERELISATION OF WATER WITH BLEACHING POWDER VinayakSoni15
 
203979153 investigatory-project-on-ldr (1)
203979153 investigatory-project-on-ldr (1)203979153 investigatory-project-on-ldr (1)
203979153 investigatory-project-on-ldr (1)Chiranjeet Samantaray
 
47363797 chemistry-project-on-soft-drink
47363797 chemistry-project-on-soft-drink47363797 chemistry-project-on-soft-drink
47363797 chemistry-project-on-soft-drinkPrateek Dhokwal
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmhome
 
Chemistry Project for class 12 on a comparative study on different brands of ...
Chemistry Project for class 12 on a comparative study on different brands of ...Chemistry Project for class 12 on a comparative study on different brands of ...
Chemistry Project for class 12 on a comparative study on different brands of ...RemaDeosiSundi
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Pythonvikram mahendra
 

Was ist angesagt? (20)

chemistry investigatory project class 12
chemistry investigatory project class 12chemistry investigatory project class 12
chemistry investigatory project class 12
 
Computer Science Investigatory Project Class 12
Computer Science Investigatory Project Class 12Computer Science Investigatory Project Class 12
Computer Science Investigatory Project Class 12
 
Computer science project.pdf
Computer science project.pdfComputer science project.pdf
Computer science project.pdf
 
Chemistry investigatory project for everyone
Chemistry investigatory project for everyoneChemistry investigatory project for everyone
Chemistry investigatory project for everyone
 
content of cold drinks available in the market-chemistry investigatory project
content of cold drinks available in the market-chemistry investigatory projectcontent of cold drinks available in the market-chemistry investigatory project
content of cold drinks available in the market-chemistry investigatory project
 
C++ COMPUTER SCIENCE PROJECT
C++ COMPUTER SCIENCE PROJECTC++ COMPUTER SCIENCE PROJECT
C++ COMPUTER SCIENCE PROJECT
 
Chemistry project on cold drinks
Chemistry project on cold drinksChemistry project on cold drinks
Chemistry project on cold drinks
 
cbse 12th chemistry investigatory project
cbse 12th chemistry investigatory project cbse 12th chemistry investigatory project
cbse 12th chemistry investigatory project
 
IP Project for Class 12th CBSE
IP Project for Class 12th CBSEIP Project for Class 12th CBSE
IP Project for Class 12th CBSE
 
Foaming Capacity of Soap
Foaming Capacity of SoapFoaming Capacity of Soap
Foaming Capacity of Soap
 
CBSE class 12th Chemistry project on antacids for cbse aissce 2017-2018
CBSE class 12th Chemistry project on antacids for cbse aissce 2017-2018CBSE class 12th Chemistry project on antacids for cbse aissce 2017-2018
CBSE class 12th Chemistry project on antacids for cbse aissce 2017-2018
 
Chemistryinvestigatory 130128120104-phpapp01 (1)
Chemistryinvestigatory 130128120104-phpapp01 (1)Chemistryinvestigatory 130128120104-phpapp01 (1)
Chemistryinvestigatory 130128120104-phpapp01 (1)
 
STERELISATION OF WATER WITH BLEACHING POWDER
STERELISATION OF WATER WITH BLEACHING POWDER STERELISATION OF WATER WITH BLEACHING POWDER
STERELISATION OF WATER WITH BLEACHING POWDER
 
203979153 investigatory-project-on-ldr (1)
203979153 investigatory-project-on-ldr (1)203979153 investigatory-project-on-ldr (1)
203979153 investigatory-project-on-ldr (1)
 
Ip project
Ip projectIp project
Ip project
 
47363797 chemistry-project-on-soft-drink
47363797 chemistry-project-on-soft-drink47363797 chemistry-project-on-soft-drink
47363797 chemistry-project-on-soft-drink
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEm
 
Chemistry Project for class 12 on a comparative study on different brands of ...
Chemistry Project for class 12 on a comparative study on different brands of ...Chemistry Project for class 12 on a comparative study on different brands of ...
Chemistry Project for class 12 on a comparative study on different brands of ...
 
Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)
Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)
Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Python
 

Andere mochten auch

Ip project work test your knowledge
Ip project work test your knowledgeIp project work test your knowledge
Ip project work test your knowledgeKïShørê Choudhary
 
Modul Kelas Programming : Java MySQL
Modul Kelas Programming : Java MySQLModul Kelas Programming : Java MySQL
Modul Kelas Programming : Java MySQLFgroupIndonesia
 
Best Way to Write SQL in Java
Best Way to Write SQL in JavaBest Way to Write SQL in Java
Best Way to Write SQL in JavaGerger
 
PPT FOR ONLINE HOTEL MANAGEMENT
PPT FOR ONLINE HOTEL MANAGEMENTPPT FOR ONLINE HOTEL MANAGEMENT
PPT FOR ONLINE HOTEL MANAGEMENTJaya0006
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentationSaad Symbian
 

Andere mochten auch (7)

Ip project work test your knowledge
Ip project work test your knowledgeIp project work test your knowledge
Ip project work test your knowledge
 
Ip project visual mobile
Ip project visual mobileIp project visual mobile
Ip project visual mobile
 
Modul Kelas Programming : Java MySQL
Modul Kelas Programming : Java MySQLModul Kelas Programming : Java MySQL
Modul Kelas Programming : Java MySQL
 
Best Way to Write SQL in Java
Best Way to Write SQL in JavaBest Way to Write SQL in Java
Best Way to Write SQL in Java
 
PPT FOR ONLINE HOTEL MANAGEMENT
PPT FOR ONLINE HOTEL MANAGEMENTPPT FOR ONLINE HOTEL MANAGEMENT
PPT FOR ONLINE HOTEL MANAGEMENT
 
Investigatory Project
Investigatory ProjectInvestigatory Project
Investigatory Project
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentation
 

Ähnlich wie informatics practices practical file

Ähnlich wie informatics practices practical file (20)

Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
Include
IncludeInclude
Include
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
 
Libtcc and gwan
Libtcc and gwanLibtcc and gwan
Libtcc and gwan
 
Libtcc and gwan
Libtcc and gwanLibtcc and gwan
Libtcc and gwan
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Effective C#
Effective C#Effective C#
Effective C#
 
Array Cont
Array ContArray Cont
Array Cont
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
Lập trình C
Lập trình CLập trình C
Lập trình C
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
C++11
C++11C++11
C++11
 

Mehr von Sai Sathvick Chirakala (9)

Characteristics of healthy personality
Characteristics of healthy personalityCharacteristics of healthy personality
Characteristics of healthy personality
 
My Sql
My Sql My Sql
My Sql
 
Mysql and html
Mysql and html Mysql and html
Mysql and html
 
Physics project class 12 EMI
Physics project class 12 EMIPhysics project class 12 EMI
Physics project class 12 EMI
 
02 chapter 11 thermodynamics
02 chapter 11 thermodynamics02 chapter 11 thermodynamics
02 chapter 11 thermodynamics
 
Chapter 11 equilibrium lecture notes
Chapter 11 equilibrium lecture notesChapter 11 equilibrium lecture notes
Chapter 11 equilibrium lecture notes
 
Class ion exchange 22 oct 08
Class ion exchange 22 oct 08Class ion exchange 22 oct 08
Class ion exchange 22 oct 08
 
The frog and the nightingle
The frog and the nightingleThe frog and the nightingle
The frog and the nightingle
 
Congruence of triangle
Congruence of triangleCongruence of triangle
Congruence of triangle
 

Kürzlich hochgeladen

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Kürzlich hochgeladen (20)

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

informatics practices practical file

  • 2. JAVA PROGRAMMING Q1.Design a java program to print the table of the entered number? Ans. Preview- Source Code- Code for Table private void jButton1ActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: int x= Integer.parseInt(AT.getText()); inty,z=0; for(y=1;y<=10;++y) { z=y*x; RT.append(z+"n"); }}
  • 3. Code for Clear private void clearActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: AT.setText(" "); RT.setText(" "); } Q2.Design a java program to print the Fibonacci series of the entered number? Ans. Preview- Source Code- Code for Fibonacci private void jButton2ActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: int s1=0,s2=1,sum,n; n=Integer.parseInt(AT.getText()); if(n==0) RT.append(0+"n");
  • 4. else if(n==1) RT.append(0+"n"+1+"n"); else { RT.append(0+"n"+1+"n"); RT.append(""); for(inti=2; i<=n; i++) { sum=s1+s2; RT.append(sum+"n"); RT.append(" "); s1=s2; s2=sum; } } } Code for Clear private void clearActionPerformed (java.awt.event.ActionEventevt) { // TODO add your handling code here: AT.setText(""); RT.setText(""); }
  • 5. Q3.Design a java program to display the scored goal details and match result? Ans. Preview- Source Code- Code for Scored By A private void GOAActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: intga= Integer.parseInt(tAGoals.getText()); ga=ga+1; tAGoals.setText(""+ga); } Code for Scored By B private void GOBActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: intgb= Integer.parseInt(tBGoals.getText()); gb=gb+1; tBGoals.setText(""+gb); }
  • 6. Code for Declare Match private void DCActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: intga=Integer.parseInt(tAGoals.getText()); intgb=Integer.parseInt(tBGoals.getText()); String res=(ga>gb?"Team A wins":(ga<gb)?"Team B wins":"Draw"); result.setText(res); } Code for Clear private void CLEARActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: result.setText(" "); tBGoals.setText("0"); tAGoals.setText("0"); } Q4. Design a java program to add the Digits in input area? Ans. Preview-
  • 7. Code of main methodintaddDigits(int n){int s=0; int dig; while(n>0){ dig=n%10; s=s+dig; n=n/10; }return s; } Code for Compt……….. Buttonintnum=Integer.parseInt(input.getText()); int sum=addDigits(num); out.setText("Sum of its digits is "+sum);
  • 8. Q5. Design a java program to change background colour of different input controls ? Ans. Preview- Code for the jList (Event –ListSelection-valueChanged)private void ColValueChanged(javax.swing.event.ListSelectionEventevt) { // TODO add your handling code here: inti; Color x=Color.WHITE; i=Col.getSelectedIndex(); switch(i){ case 0: x=Color.RED; break; case 1: x=Color.BLUE; break;
  • 9. case 2: x=Color.GREEN; break; case 3: x=Color.MAGENTA; break; case 4: x=Color.CYAN; break; case 5: x=Color.YELLOW; break; case 6: x=Color.GRAY; break; } if(LBL1.isSelected()) Lb.setBackground(x); else Lb.setBackground(Color.WHITE); if(LBL2.isSelected()) Btn.setBackground(x); else Btn.setBackground(Color.WHITE); if(LBL3.isSelected()) TF.setBackground(x); else TF.setBackground(Color.WHITE);
  • 10. Q6. Design a java program to select the character from the list as given in textfield? Ans. Preview- Code of Select in List Buttonprivate void oKActionPerformed(java.awt.event.ActionEventevt) { // TODO add your handling code here: List.setSelectedValue(ENTER.getText(), true);
  • 11. Q7.Design a java program to print the numbers in between the given input? Ans. Code of Count Buttonint a=Integer.parseInt(IN1.getText()); int b=Integer.parseInt(IN2.getText()); if(a>b){ for(;b<=a;b++) {OUT.append(b+" ");} } else{ for(;a<=b;a++) { OUT.append(a+" ");} }
  • 12. Q8. Design a java program to check a string is palindrome or not? Ans. Code of Perform Palindrome Test ButtonString str=In.getText(); showPalindrome(str); Main method Codepublic void showPalindrome(String s){ StringBuffer out=new StringBuffer(s); if(isPalindrome(s)) s=s+": is a palindrome!"; else if(isPalindrome2(s)) s=s+ ": is a palindrome if you ignore case"; else
  • 13. s=s+": is not a palinidrome! "; Out.setText(s); } publicbooleanisPalindrome(String s) {StringBuffer reversed=(new StringBuffer(s)).reverse(); returns.equalsIgnoreCase(reversed.toString()); } publicboolean isPalindrome2(String s) {StringBuffer reversed=(new StringBuffer(s)).reverse(); returns.equalsIgnoreCase(reversed.toString()); }
  • 14. Q9. Design a java program to reverse a string? Ans. Code of Reverse ButtonString a=IN.getText(); String b=""; for(inti=a.length()-1;i>=0;i--){ b=b+a.charAt(i); }OUT.setText(b);
  • 15. Q10. Design a java program to find the occurrence of a character? Ans. Code of Count ButtonString a=In1.getText(); char b=In2.getText().charAt(0); int c=0; for(int d=0;d<a.length();d++){ if(a.charAt(d)==b) c++; } Out.setText (""+c);
  • 16. Q11. Design a java program to find the position of a vowel in a string? Ans. Code of OK Button// TODO add your handling code here: String a=IN.getText(); for(int d=0;d<=a.length();d++){ char c=a.charAt(d); switch(c){ case 'a': case 'A': case 'e': case 'E': case 'i': case 'I':
  • 17. case 'o': case 'O': case 'u': case 'U': d=d+1; OUT.append(" "+d+"n"); break; default: } } Q12. Design a java program to display a menu of Ice-cream parlour ? Ans. Code of Calculate Buttonif(St.isSelected()==true) { STP.setText("35");}
  • 19. VAT.setText(""+a9); a10=a7+a8+a9; OUT.setText(a10+""); Code of Clear ButtonSt.setSelected(false); Ch.setSelected(false); Va.setSelected(false); STT.setText(""); VAT.setText(""); CHT.setText(""); OUT.setText(""); STQ.setText(""); VAQ.setText(""); CHQ.setText(""); VAP.setText(""); STP.setText(""); CHP.setText(""); Code of Exit ButtonSystem.exit (0);
  • 20. Q13. Design a class program to display a detail of a book ? Ans. Class Methodpublic class book { String name,author; int edition; float price; public book(){ this.name=""; this.author=""; edition=2000; price=100.0f; } public book(String a,Stringb,intc,float d){ this.name=a; this.author=b; edition=c; price=d; } void display(){ System.out.println("Name of the book is "+name); System.out.println("Author of book is "+author); System.out.println("Edition:-"+edition); System.out.println("Price:-"+price);
  • 21. } Main Methodbook B1=new book ("The Canterville Ghost”, “Oscar Wilde",2012,55); B1.display (); Q14. Design program to display a student record table ? Ans. Class Methodvoid process(){ int a=0; String name="",hname=""; doubleperc=0.0,hperc=0.0; do{name=JOptionPane.showInputDialog("Enter Student's name:"); perc=Double.parseDouble(JOptionPane.showInputDialog("Enter Percentage Marks:")); resTa.append(name+"t"+perc+"n");
  • 22. if(hperc<perc){ hperc=perc; hname=name; } a=JOptionPane.showConfirmDialog(null,"More Student info??"); } while(a==JOptionPane.YES_OPTION); if(a==JOptionPane.NO_OPTION){ JOptionPane.showMessageDialog(null,"Highest scorer is "+hname+" with "+hperc+"marks. "); } } Main MethodJOPdialogs j1=new JOPdialogs(); j1.setVisible(true); j1.process(); j1.setVisible(false);
  • 23. Q15. Design a class program to print detail of a student? Ans. Class Methodpublic class Student{ introllNumber = 0; String name = "nil"; public Student(intrno,Stringsname){ rollNumber=rno; name=sname; } void display(){ System.out.println("RollNumber ="+rollNumber); System.out.println("Name ="+name); } Main MethodStudentB1=new Student(23,"GOVIND"); B1.display(); } }