Here are the Mumbai University First Year Engineering sem-2 Computer programing 2 (CP-2) programs.These are tried and tested and work just fine.Njoy!
Please refer this to all your pals on all your social networks..thank you !
The grey color is only for the background it should cause no problems.
--------------------------------------------------------------------------------------------------------------
/*Program to convert integers entered by user into words:
INPUT:1234 Output would be : one two three four*/
import java.io.*;
class Pwords {
public static void main(String args[]) throws Exception
{
DataInputStream ob=new DataInputStream(System.in);
System.out.print("Enter a number: ");
int x = Integer.parseInt(ob.readLine());
int temp;
String str = "";
while (x != 0)
{
temp = x % 10;
switch (temp)
{
case 1: str = "one " + str; break;
case 2: str = "two " + str; break;
case 3: str = "three " + str; break;
case 4: str = "four " + str; break;
case 5: str = "five " + str; break;
case 6: str = "six " + str; break;
case 7: str = "seven " + str; break;
case 8: str = "eight " + str; break;
case 9: str = "nine " + str; break;
case 0: str = "zero " + str; break;
}
x /= 10;
}
System.out.println("Number in words: " + str);
}
}
search
Sunday, June 13, 2010
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment