#### Words of Wisdom:

"Real racers drive straight to the finish line, those other guys just drive in circles looking for it." - Aaron19888

# Computer Project

• Date Submitted: 12/17/2011 10:53 PM
• Flesch-Kincaid Score: 85.6
• Words: 379
• Report this Essay
Q.no.1: Write a program to perform the function of tower of hanoi…

A.no.1:

import java.io.*;
class tower
{
public void transfer(int n,char from,char to,char temp)
{
if(n>0)
{
transfer(n-1,from,temp,to);
System.out.println("Move disc "+n+" from "+from+" "+"to "+to);
transfer(n-1,temp,to,from);
}
return;
}
public static void main(String args[])throws IOException
{
tower ob=new tower();
int n;
System.out.println("How many discs...???");
ob.transfer(n,'A','B','C');
}
}
Output:

How many discs...???
3
Move disc 1 from A to B
Move disc 2 from A to C
Move disc 1 from B to C
Move disc 3 from A to B
Move disc 1 from C to A
Move disc 2 from C to B
Move disc 1 from A to B

Algorithm:

Operation— Tower of Hanoi.
Input— Number of discs.
Output— Position of discs.

Steps—

1): define the class name “tower”.
2): start a function “transfer”, with

Q.no.2. Write a program to accept a word or a sentence and display it in PIGLATIN form.

A.no.2.

import java.io.*;
class piglatin
{
private String str;
public void input()throws IOException
{
System.out.println("Enter the String");
}
public void latin()throws IOException
{
int p,k=0,x=0,y;
String c,d,a="";
char b=' ',ch=' ';
str=str+' ';
p=str.length();
System.out.println("The string in pig latin form: ");
for(int m=0;mb)
{
int c=a;
a=b;
b=c;
}
}
public int rec_hcf(int a,int b)
{
if(b==0)
{
return a;
}
else
{
return rec_hcf(b,a%b);
}
}
public int fn_lcm(int a,int b,int c)
{
int k=a*b;
int d=k/c;
return d;
}
public void result()
{
hcf=rec_hcf(a,b);
System.out.println("HCF...