Sunteți pe pagina 1din 22

All India Senior School Certificate

Examination 2015-2016

Program File
Informatics Practices
Saksham Gupta
Class: XII F
Roll No: 1644687

Submitted To:
Mr. RAVI KUMAR
Computer Department

Certificate
This is hereby to

certify

that

the

original

and

genuine investigation work has been carried out to


investigate

about

the

subject

matter

and

the

related data collection and investigation has been


completed solely, sincerely and

satisfactorily

by

Saksham Gupta of CLASS XII F, BIRLA


SCHOOL, PILANI , regarding

his

program file titled

Program File under my supervision for partial


fulfillment of the Practical Examination of Class XII of
All India Senior School Certificate Examination

2010 - 2011.

Teachers Signature

Acknowledgement
It would be my utmost pleasure to express my most
sincere gratitude and own a grave sense of thankfulness
to my Informatics Practices teacher Mr. RAVI KUMAR
SAINI , Sr. computer teacher ,Informatics Practices ,
BIRLA SCHOOL PILANI , for his valuable guidance,
incommensurate indoctrination , support and supervision
all through the building of this program file which has
been responsible for present form of the program file
Program File.
I am also thankful to Mr.Virender and Mr.Vikash without
whose help the successful completion of the project
would not have been possible.
I would also like to thank my parents as they
encouraged me to put forward my project.

Saksh
am Gupta

XII F

Contents
Introduction

o System Requirements

Programs
o Program to find factorial of two numbers.
o Program to find the logarithmic value of one number with
respect to base inputted by the user.
o Program to ask permutations of a whole number and its base
which randomly generated.
o Program to find if a String is palindrome or not.
o Program to ask nth root of a random number.
o Program to ask area of body of random dimensions.
o Program To find the sum of first n odd numbers
o Program of classes to print system date.
o Program of loop to print the output
o Program of loop to print the output
o Program of loop to print the output
o Program of loop to print the output
o Program of loop to print the output
o Program of loop to print the output
o Program of class to print the sum series upto n terms:
o Program of class to print the sum of factorials of first n
numbers:
o Program to check entry through use of password
o Program to design a Calculator
o Program to count from highest to lowest number input by
user

Bibliography

Introduction
System Requirements
Intel Pentium 4 Processor or Better
Windows XP/Vista
Java
Java Runtime
256 MB RAM
CD-Rom
1 GB Hard Disk Free
Application Development IDE USED:
Netbeans IDE 6.5.1

Programs
Program to find factorial of two numbers.

Coding For FactBtn:


{int num = Integer.parseInt(tf1.getText());
long i = 0, fact =1;
i=num;
while(num!=0){
fact = fact*num;
--num;}
int num1 = Integer.parseInt(tf2.getText());
long f = 0, fact1 =1;
f=num1;
while(num1!=0){
fact1 = fact1*num1;
--num1;}
Reslbl.setText("Your Factorial of "+i+" is "+fact+" And Factorial of "+f+" is "+fact1);}

Program to find the logarithmic value of one number


with respect to base inputted by the user.

Coding For LogBtn:


{
double num1 = Double.parseDouble(tf1.getText());
double num2 = Double.parseDouble(BaseTf.getText());
double num3;
if (num1>0){
num3 = Math.log(num1)/Math.log(num2);
Reslbl.setText(" Your ans = "+num3+".");
tf1.setText("");
BaseTf.setText("");}

else
Reslbl.setText(" Invalid input number. Enter positive number");
}

Program to ask permutations of a whole number and


its base which randomly generated.

import java.util.Random;

Coding For QUETIONBtn:


{Random RandGen = new Random();
int num , base;
do{
num = RandGen.nextInt((15));
base = RandGen.nextInt((15));
if (num>base){
NoLBL.setText(""+num);
BaseLbl.setText(""+base);
}while(num < base); }

GuEBtn.setEnabled(true);

Coding For GuessBtn:


{ int num = Integer.parseInt(NoLBL.getText());
int base = Integer.parseInt(BaseLbl.getText());
long solution=1;
for (int c = num;c >(num-base);c--)
solution =solution*c;

long res = Long.parseLong(ValueTF.getText());


if (solution==res){
ReturnLBL.setText( Your answer is correct.The permutation is indeed "+solution);
}
else ReturnLBL.setText( Your answer is not correct.The permutation is "+solution);
}

Program to find if a String is palindrome or not.

Functions:
public boolean isPalindrome(String s){
StringBuffer reversed = (new StringBuffer(s)).reverse();
return s.equals(reversed.toString());}
public boolean isPalindrome2(String s){
StringBuffer reversed = (new StringBuffer(s)).reverse();
return s.equalsIgnoreCase(reversed.toString());}

Coding For PalindromeBtn:


{ String str = Text.getText();

if(isPalindrome(str))
str = str+" : IS A PALINDROME! ";
else if(isPalindrome2(str))
str = str+" : IS A PALINDROME IF YOU IGNORE CASE!";
else
str = str+" : IS NOT A PALINDROME!";
OutputLbl.setText(str);}
}

Program to ask nth root of a random number.

import java.util.Random;

Coding For QuesBtn:


{ Random RandGen = new Random();
int num = RandGen.nextInt((9999));
int root=0 ;
for (;root==0;root++){
root = RandGen.nextInt((10));}
nolbl.setText(""+num);

Rootlbl.setText(""+root);
GuessBtn.setEnabled(true);
}

Coding ForGuessBtn:
{ float num = Float.parseFloat(nolbl.getText());
float root = Float.parseFloat(Rootlbl.getText());
float a = 1/root;
float ans = (float)Math.pow(num,a);
float res = Float.parseFloat(Valuetf.getText());
if(ans==res){
ReturnLbl.setText( Your answer is correct.It is indeed "+ans);
}
else ReturnLbl.setText(Your answer is not correct.It is "+ans);
}

Program to ask area of body of random dimensions.

import java.util.Random;

Coding For QuestionBtn:

Random RandGen = new Random();


int len = RandGen.nextInt((999));
int bre = RandGen.nextInt((999));
lenLbl.setText(""+len);
BreLbl.setText(""+bre);
GuessBtn.setEnabled(true);

Coding For GuessBtn:


{ int len = Integer.parseInt(lenLbl.getText());
int bre = Integer.parseInt(BreLbl.getText());
double area = 0;
if(Cir_RB.isSelected()== true){
area = len*len*3.1416;
}
else if(Rec_RB.isSelected()== true){
area = len*bre;
}
else if(Tri_RB.isSelected()== true){
area = len*bre*0.5;}
double res = Double.parseDouble(ANSTf.getText());
if (area==res){
Result_Lbl.setText( Your answer is correct.The area is indeed "+area);
}
else Result_Lbl.setText(Your answer is not correct.The area is "+area); }

Program To find the sum of first n odd numbers

Coding For SumBtn:


{int n = Integer.parseInt(numTF.getText());
int sum,a=1;
for(int i =1;i<=n;i++){
sum +=a;
a+=2;
}ResultLbl.setText(Sum of first +n+ Odd Numbers =+sum );
}

Program of classes to print system date.


import java.util.*;

Coding:
public class Date_Class{
static public void main(String[] args) {
Date d=new Date();
System.out.println("The Date is" +d);}}

Program of loop to print the output as :


*
* *
* * *
* * * *
Coding:
for (int i =1; i< 5;++i){
for(int j =1;j<=i;++j){
System.out.print(*+ );}
System.out.println();
}

Program of loop to print the output as :


1
1 2
1 2 3
1 2 3 4
Coding:
for (int i =1; i< 5;++i){
for(int j =1;j<=i;++j){
System.out.print(j+ );}
System.out.println();
}

Program of loop to print the output as :

9
9 8
9 8 7
9 8 7 6
Coding:
for (int i =9; i> 5;--i){
for(int j =9;j>=i;--j){
System.out.print(j+ );}
System.out.println();}

Program of loop to print the output as :


d
d c
d c b
d c b a
Coding:
for(char i ='d'; i>='a';--i){
for(char j ='d';j>=i;--j){
System.out.print(j+ " " );}
System.out.println();}

Program of loop to print the output as :


a
b c
d e f
Coding:
char a ='a';

for(int i =1; i<=3;++i){


for(int j =1;j<=i;++j){
System.out.print(a+ " " );
++a;}
System.out.println();}

Program of loop to print the output as :


A B C
B C
C
Coding:
for(char i ='A'; i<='C';++i){
for(char j =i;j<='C';++j){
System.out.print(j+ " " );}
System.out.println();
}

Program of class to print the sum series upto n


terms:
1+1/4+1/7+1/10+1/13+1/16+.
Coding:
import javax.swing.JOptionPane;
public class Print_Series{
static public void main(String[] args) {
int num = Integer.parseInt(JOptionPane.showInputDialog(null, "Input n"));
double sum=0,term=0,n = 0;
for(double x =1;n<num;x+=3,n++){

term = 1/x;
sum+=term;}
JOptionPane.showMessageDialog(null, "THE SUM IS "+sum);}}

Program of class to print the sum of factorials of first


n numbers:
Coding:
import javax.swing.JOptionPane;
public class Print_Sum{
static public void main(String[] args) {
int num = Integer.parseInt(JOptionPane.showInputDialog(null,"Input n"));
int sum = 0;
for(int x =1;x<=num;x++){
int term=1;
for (int a =1;a<=x;a++){
term *=a;}
sum+=term;}
JOptionPane.showMessageDialog(null,"THE SUM IS "+sum);}}

Program to check entry through use of password

import javax.swing.JOptionPane;

Coding For NextBtn:


String name = NAMETF.getText();
String javed = new String (PASSTF.getPassword());
if(javed.equals("javed")){
JOptionPane.showMessageDialog(null,Entry Successful);
}
else{JOptionPane.showMessageDialog(null,Incorrect Password);}

Coding For ClearBtn:


NAMETF.setText("");
PASSTF.setText("");

Program to design a Calculator

private void DigitPressed(java.awt.event.ActionEvent evt) {


String txt = evt.getActionCommand();
String calcval = tf2.getText();
if(txt.equals("dig0"))

tf2.setText(calcval+"0");

if (txt.equals("dig1")) Field.setText(calcval+"1");
if(txt.equals("dig2")) tf2.setText(calcval+"2");
if (txt.equals("dig3")) tf2.setText(calcval+"3");
if(txt.equals("dig4")) tf2.setText(calcval+"4");
if (txt.equals("dig5")) tf2.setText(calcval+"5");
if(txt.equals("dig6")) tf2.setText(calcval+"6");
if (txt.equals("dig7")) tf2.setText(calcval+"7");
if(txt.equals("dig8")) tf2.setText(calcval+"8");
if(txt.equals("dig9")) tf2.setText(calcval+"9");
if (txt.equals("dig.")) tf2.setText(calcval+".");}

Coding For DivBtn:

double num1 = Double.parseDouble(tf1.getText());


double num2 = Double.parseDouble(tf2.getText());
double num3;
if(num2==0){
Reslbl.setText("Cannot divide by zero");
}
else{
num3= num1 / num2;
Reslbl.setText( Your ans = "+num3) ;
}

Coding For AddBtn:


double num1 = Double.parseDouble(tf1.getText());
double num2 = Double.parseDouble(tf2.getText());
double num3 = num1 + num2;
Reslbl.setText( Your ans = "+num3) ;

Coding For SubBtn:


double num1 = Double.parseDouble(tf1.getText());
double num2 = Double.parseDouble(tf2.getText());
double num3 = num1 - num2;
Reslbl.setText( Your ans = "+num3) ;

Coding For MulBtn:


double num1 = Double.parseDouble(tf1.getText());
double num2 = Double.parseDouble(tf2.getText());
double num3 = num1 - num2;
Reslbl.setText( Your ans = "+num3) ;

Program to count from highest to lowest number


input by user

Coding For Count_Btn:


ResLbl.setText("");
int num1 = Integer.parseInt(Num1Tf.getText());
int num2 = Integer.parseInt(Num2Tf.getText());
int y = Math.max(num1,num2);
for(int x = Math.min(num1,num2);x<=y;x++){
String res = ResLbl.getText();
ResLbl.setText(res+x+" ");}

Bibliography

Informatics Practices
Dhanpat Rai & co. Class XII textbook

Informatics Practices
Dhanpat Rai & co. Class XI textbook

S-ar putea să vă placă și