Anda di halaman 1dari 13

Information

Practices

Name: Abhinav Pandey


Class: 11-B
Roll-No: 16
Q1. To find Volume of Cube & Cuboid
private void volumeActionPerformed(java.awt.event.ActionEvent evt) {

int ch,lngt,brdt,high,cvol,cbdvol;

ch=Integer.parseInt(chc.getText());

lngt=Integer.parseInt(lng.getText());

brdt=Integer.parseInt(brd.getText());

high=Integer.parseInt(hgh.getText());

cvol=lngt*lngt*lngt;

cbdvol=lngt*brdt*high;

switch (ch) {

case 1: lbl.setText("That's a Cube");

result.setText("its perimeter is "+cvol);

break;

case 2: lbl.setText("That's a Cuboid");

result.setText("its perimeter is "+cbdvol);

break;

default:lbl.setText("Please Enter a valid Choise. i.e. 1 or 2");}

2. To find area of shapes


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

float ss,recl,recb,cirr,sqra,reca,cira;

float pi=22/7;

ss=Float.parseFloat(sqs.getText());

recl=Float.parseFloat(rl.getText());

recb=Float.parseFloat(rb.getText());

cirr=Float.parseFloat(rc.getText());

sqra=ss*ss;

reca=recl*recb;

cira=pi*cirr*cirr;

sqa.setText(""+sqra);

ra.setText(""+reca);

ca.setText(""+cira);}

3. To find Factorial of number


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

int num,result=1,i;

num=Integer.parseInt(t1.getText());

for (i=1;i<=num;i++){

result=result*i;

t2.setText(""+result);

4. To check a number is prime or Composite


class PrimeNo{

public static void main(String args[]){

int num = Integer.parseInt(args[0]);

int flag=0;

for(int i=2;i<num;i++){

if(num%i==0)

System.out.println(num+" is a Composite NUmber");

flag = 1;

break;}

if(flag==0)

System.out.println(num+" is a Prime Number");

5. To find Largest of 3.
private void largestActionPerformed(java.awt.event.ActionEvent evt) {

int n1,n2,n3,lrg;

n1=Integer.parseInt(num1.getText());

n2=Integer.parseInt(num2.getText());

n3=Integer.parseInt(num3.getText());

if (n1>n2&&n1>n3)

res.setText(""+n1);

else if (n2>1&&n2>n3)

res.setText(""+n2);

else

res.setText(""+n3);

6. To find grades.
7. WAP to find the reverse of number
public static void main(String[] args) {

int num,reverse=0;

Scanner input=new Scanner (System.in);

System.out.print ("enter a number :");

num=input.nextInt();

while (num!=0){

reverse = reverse*10;

reverse = reverse +num%10;

num=num/10;

System.out.print ("reverse of input number is : "+reverse+"\n");

8. To find Sum of Digits of Numbers


class DigitSum

public static void main(String args[])

int i,a=0, sum=0;

i=Integer.parseInt(args[0]);

while(i!=0)

a=i%10;

i=i/10;

sum=sum+a;

System.out.println(sum);

9. To find Prime Numbers Between 2 to 100


public static void main(String[] args) {

int i ;

int num ;

String primeNumbers="";

for (i = 2; i <= 100; i++){

int counter=0;

for(num =i; num>=1; num--){

if(i%num==0){

counter = counter + 1;

if (counter ==2){

primeNumbers = primeNumbers + i + " ";

System.out.println("Prime numbers from 2 to 100 are :");

System.out.println(primeNumbers);

10. To find Sum of 10 even numbers


public static void main(String[] args) {

int num=0,i=0;

Scanner input=new Scanner (System.in);

for (i=1;i<=10;i++){

System.out.print ("enter a number :");

num=num+input.nextInt();

System.out.println("the sum of all 10 numbers are "+num);

11. a)Select all NonMedical Students.


Select * from Student1 Where Stream="NonMedical";
b) List name of those students who are in class 12 order by Stipend.
Select Name from Student1 Where Class like "12%" Order by Stipend;

c) List all Students Sorted by AvgMark.


Select * from Student1 Order by AvgMark desc;

d) Display a Report, Listing Name, Stipend, and Stream. (Stipend*12)


Select Name, Stipend*12,Stream from Student1;

Anda mungkin juga menyukai