The Artima Developer Community
Sponsored Link

Java Answers Forum
whats lacking in my program?

3 replies on 1 page. Most recent reply: Sep 19, 2005 3:22 AM by Jeff Thomson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
marjorjie

Posts: 6
Nickname: jorj
Registered: Sep, 2005

whats lacking in my program? Posted: Sep 16, 2005 7:07 PM
Reply to this message Reply
Advertisement
this is my program...i think there is lacking...but i dont know what...kindly run this and edit... thanks!!!

import java.io.*;

public class CheckWriter{

private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

public static void main (String[]args)throws Exception{

String chan;
do{

String name=getName();
String date=getDate();
String receive=getReceive();
double amount=getamount();
int amt=(int) amount;

int b=getcents(amt,amount);
String inwords=getword(amt);
String cents=getword(b);


System.out.println("*********************************************************** *********************");
System.out.println("\t\t\t GOLDEN BANK");
System.out.println("\n\n\t\t\t\t\tDATE (MM/DD/YYYY):"+date+"\n\n\n");
System.out.println("Pay To The Order Of:"+ name + " \t\tAmount:" + amount + "\n\n" );
System.out.print("Amount in Words :"+inwords + "Pesos and "+cents +"Centavos"+"\n\n\n");
System.out.println("TO:"+receive);
System.out.println("\t\t\t\t\n\n\t\t\t\t\t Signature:________________________");
System.out.println("\n\n\n\n*************************************************** *****************************");



do{
System.out.println("LiKe tO rEpEaT? yes or no?");
chan = in.readLine();

if (!(chan.equalsIgnoreCase("yes")||chan.equalsIgnoreCase("no")))
System.out.println("\n\n\n\twRoNg InPuT!!! EnTeR tHe CoRrEcT InPuT pLeAsE...\n\n\n");

}while (!(chan.equalsIgnoreCase("yes")||chan.equalsIgnoreCase("no")));
System.out.println("\n\n");

}while (!(chan.equalsIgnoreCase("no")));
System.out.println("\n\n\n\t\t\t\tThAnK YoU!\n\n\n\t\t\t\thAvE a NiCe Day!!!\n\n\n\n\n");


}
public static int getcents(int x,double y){
double j=(double) x;
double a=y-j;
double c=(a+.001)*100;
int d = (int) c;

return d;
}

public static String getDate()throws Exception{
System.out.print("DATE (MONTH/DAY/YEAR):");
String str=in.readLine();
return str;
}
public static String getName()throws Exception{
System.out.print("Pay To The Order Of :");
String str=in.readLine();
return str;
}
public static double getamount() throws Exception{
System.out.print("Enter amount in figure:");
String str = in.readLine();
return Double.parseDouble(str);
}
public static String getReceive() throws Exception{
System.out.print("Enter name and address of the receiver: ");
String str=in.readLine();
return str;
}
public static String getword(int amount){

String NumInWords=" ";

if(amount>=1000000){
NumInWords+=getword(amount/1000000)+" Million ";
amount=amount%1000000;
}
if (amount>=1000){
NumInWords+=getword(amount/1000)+" Thousand ";
amount=amount%1000;
}
if (amount>=100){
NumInWords+=getdigit(amount/100)+" Hundred ";
amount=amount%100;
}
if (amount>=20){
NumInWords+=gettens(amount/10)+" ";
amount=amount%10;

}
if (amount>=10){
NumInWords+=getteen(amount)+" ";

}
if (amount>=0){
NumInWords+=getdigit(amount)+" ";
}

return NumInWords;
}
public static String gettens(int amount){

String number=" ";

switch(amount)
{
case 2:number="Twenty";
break;
case 3: number="Thirty";
break;
case 4: number="Forty";
break;
case 5: number="Fifty";
break;
case 6: number="Sixty";
break;
case 7: number="Seventy";
break;
case 8: number="Eighty";
break;
case 9: number="Ninety";
break;
}
return number;

}

public static String getteen(int amount){

String number=" ";

switch(amount)
{
case 10:number="Ten";
break;
case 11: number="Eleven";
break;
case 12: number="Twelve";
break;
case 13: number="Thirteen";
break;
case 14: number="Fourteen";
break;
case 15: number="Fifthteen";
break;
case 16: number="Sixteen";
break;
case 17: number="Seventeen";
break;
case 18: number="Eighteen";
break;
case 19: number="Nineteen";
break;
}
return number;
}

public static String getdigit(int amount){

String number=" ";

switch(amount)
{
case 0: number="Zero";
break;
case 1: number="One";
break;
case 2:number="Two";
break;
case 3: number="Three";
break;
case 4: number="Four";
break;
case 5: number="Five";
break;
case 6: number="Six";
break;
case 7: number="Seven";
break;
case 8: number="Eight";
break;
case 9: number="Nine";
break;
}
return number;
}
}


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: whats lacking in my program? Posted: Sep 18, 2005 10:20 PM
Reply to this message Reply
We might bother to look at your code if you kindly
bother to indent and use the pre or java tags
so that your code is more legible.

Thanks

Samit

Posts: 1
Nickname: samit
Registered: Sep, 2005

Re: whats lacking in my program? Posted: Sep 19, 2005 2:17 AM
Reply to this message Reply
What exactly do you requuire of this program ? Coz it works as good as I see it to be working.

Jeff Thomson

Posts: 14
Nickname: thomson
Registered: Sep, 2005

Re: whats lacking in my program? Posted: Sep 19, 2005 3:22 AM
Reply to this message Reply
Hi Kiray,

What are you trying to do with the program? I have executed it and seems fine, but untill we know what you are desiring from it we cant help you attain it.

----------------
Jeff Thomson
http://www.devsquare.com
Online Application Development

Flat View: This topic has 3 replies on 1 page
Topic: Security Manager file access for mail Previous Topic   Next Topic Topic: applet source code

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use