sundar
Error
Posted in : Java Beginners

October 23, 2009 at 3:17 PM

Hi Friend,

Try it
import java.lang.*;
import java.io.*;
import java.util.*;

class constNumtoLetter{
String[] unitdo ={"", " One", " Two", " Three", " Four", " Five",
" Six", " Seven", " Eight", " Nine", " Ten", " Eleven", " Twelve",
" Thirteen", " Fourteen", " Fifteen", " Sixteen", " Seventeen",
" Eighteen", " Nineteen"};
String[] tens = {"", "Ten", " Twenty", " Thirty", " Forty", " Fifty",
" Sixty", " Seventy", " Eighty"," Ninety"};
String[] digit = {"", " Hundred", " Thousand", " Lakh", " Crore"};
int r;

//Count the number of digits in the input number
int numberCount(int num){
int cnt=0;
while (num>0){
r = num%10;
cnt++;
num = num / 10;
}
return cnt;
}
//Function for Conversion of two digit
String twonum(int numq){
int numr, nq;
String ltr="";
nq = numq / 10;
numr = numq % 10;
if (numq>19){
ltr=ltr+tens[nq]+unitdo[numr];
}
else{
ltr = ltr+unitdo[numq];
}
return ltr;
}
//Function for Conversion of three digit
String threenum(int numq){
int numr, nq;
String ltr = "";
nq = numq / 100;
numr = numq % 100;
if (numr == 0){
ltr = ltr + unitdo[nq]+digit[1];
}
else{
ltr = ltr +unitdo[nq]+digit[1]+" and"+twonum(numr);
}
return ltr;
}
}
class ActiveMQSwing{
public static void main(String[] args){
//Defining variables q is quotient, r is remainder
int len, q=0, r=0;
String ltr = " ";
String Str = "Rupees";
constNumtoLetter n = new constNumtoLetter();
System.out.println("Enter number");
Scanner input=new Scanner(System.in);
int num = input.nextInt();
if (num <= 0)
System.out.println("Zero or Negative number not for conversion");
while (num>0){
len = n.numberCount(num);
//Take the length of the number and do letter conversion
switch (len){
case 8:
q=num/10000000;
r=num%10000000;
ltr = n.twonum(q);
Str = Str+ltr+n.digit[4];
num = r;
break;
case 7:
case 6:
q=num/100000;
r=num%100000;
ltr = n.twonum(q);
Str = Str+ltr+n.digit[3];
num = r;
break;
case 5:
case 4:
q=num/1000;
r=num%1000;
ltr = n.twonum(q);
Str= Str+ltr+n.digit[2];
num = r;
break;
case 3:
if (len == 3)
r = num;
ltr = n.threenum(r);
Str = Str + ltr;
num = 0;
break;
case 2:
ltr = n.twonum(num);
Str = Str + ltr;
num=0;
break;
case 1:
Str = Str + n.unitdo[num];
num=0;
break;
default:
num=0;
System.out.println("Exceeding Crore....No conversion");
System.exit(1);
}
if (num==0)
System.out.println(Str+" Only");
}
}
}
Thanks

error
error  while iam compiling iam getting expected error
Error-
Error-   Hello, I would like to know about XSD file. I try to print XML file but I am getting error SAXException-- says Content is not allowed in prolog. Please help me
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
error
/ServletUserEnquiryForm.shtml getting an error given below SQLException caught: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error please suggest
Error
Error  I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me error as 'Unknown Runtime Error'. This error come only in IE browser, but in other brower
error
error
error
error  java.lang.unsupportedclassversionerror:bad major version at offset 6 how to solve this????   Hi, Please check the version of framework used and also the JDK version. This type error also comes when java file
error
error  When I deploye the example I have this message cannot Deploy HelloWorld Deployment Error for module: HelloWorld: Error occurred during deployment: Exception while deploying the app [HelloWorld
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern = /^\d{3,5
error
error  whats the error.............. import java.util.Scanner; public class g { public static void main(String[] args) { Scanner s=new Scanner(System.in); int d,x,y; System.out.println("Enter the first number
error
"+it); } } this is my program i am getting an error saying cannot find symbol class string
error message
error message  Sir i make one form facility with insert,update,delete.i want to error msg if any type of the data is missing and display in error msg which of the data is misssing
Permgen error
Permgen error  hi how can i solve permgen error
installation error
installation error  hi, m getting an error like " semicolon found in the selected path".how to resolve this error? during installation of jdk 1.6
error log
error log  hi my requirement is validate xml and xsd in java.If there is an errors then i will log error and store into error table. so plz if any one knows send code urgent. error table details-------------- Table
404 error
into jboss->server-> default->deploy folder it doesn't shows any error. but when i run this application by using localhost:8080/webapp ,it shows 404 error how should i slove this error
JSF error
JSF error  some of the users are not able to update the db. getting the error "An Error Occurred: Error calling action method of component with id CreateorManageOffer:jidjsp134312524923 Caused by: java.lang.NullPointerException
MAin error
MAin error  Error while running hello program in another dir rather in bin. path is already set. java -version jdk1.6.0_24 no error while compilation but @ d tym of runnin error in main class is generated Exception in thread
404 error
404 error  struts application having 404 error while hosting to a online server.it works fine in my local machine but dont work in virtual host.showing 404 error
Error display
Error display  I want to give a message on the screen that an error has occured...but I dont want to use alert and give pop up box...any other solution for the problem
JSP error
JSP error  what is difference between global-exception and error-page in jsp. which condition they are use
Tomcat Error:
Tomcat Error:   Hi, I am not able to start the tomcat server. If I try to start it then I am getting the below error. "coyote connector has not been started" Could some body please help me to solve the problem??? Thanks a ton
error in driver
error in driver  i have done connection settings for oraclethin driver in netbeans ide 6.9.1. and i was able to view tables of my database.but when i am trying to access tables from my java class i was getting error
Tutorials