program file,saksham

Upload: tanuja-gupta

Post on 09-Mar-2016

223 views

Category:

Documents


0 download

DESCRIPTION

project

TRANSCRIPT

Informatics Practices Programs

All India Senior School Certificate Examination 2015-2016

Program File

Informatics PracticesSaksham GuptaClass: XII FRoll No: 1644687

Submitted To:Mr. RAVI KUMARComputer 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 Guptaof CLASS XII F, BIRLA SCHOOL,PILANI , regarding his program filetitled 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 myInformatics 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.

Saksham Gupta XII FContents Introduction System Requirements Programs Program to find factorial of two numbers. Program to find the logarithmic value of one number with respect to base inputted by the user. Program to ask permutations of a whole number and its base which randomly generated. Program to find if a String is palindrome or not. Program to ask nth root of a random number. Program to ask area of body of random dimensions. Program To find the sum of first n odd numbers Program of classes to print system date. Program of loop to print the output Program of loop to print the output Program of loop to print the output Program of loop to print the output Program of loop to print the output Program of loop to print the output Program of class to print the sum series upto n terms: Program of class to print the sum of factorials of first n numbers: Program to check entry through use of password Program to design a Calculator Program to count from highest to lowest number input by user BibliographyIntroductionSystem 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='a';--i){for(char j ='d';j>=i;--j){System.out.print(j+ " " );}System.out.println();} Program of loop to print the output as :ab cd e fCoding:char a ='a';for(int i =1; i