Results 1 to 6 of 6
Thread: Little Help
- 09-01-2009, 01:27 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 7
- Rep Power
- 0
Little Help
I'm new to java >.>
i seem to be having a problem in having a program in money denomination i'm suppose to use while loop the process is complete and no errors but the out put solution is wrong like when i type 800 it goes
1000:0 500:1 200:-0 100:6
which is weird :p
any advice is open and i'll keep working on the money denomination thingy :D
also a character identifier ex: i typed Hello 45!!!
output:
H-Consonant Letter
e-vowel letter
l-Consonant Letter
l-Consonant Letter
o-vowel letter
4-even number
5-odd number
!-especial character
!-especial character
!-especial character
i dunno how to use an array and the tutorials i'm reading are not making any sense -.-Last edited by IWanna4get; 09-01-2009 at 01:34 PM. Reason: didn't make the thing look right :D
- 09-01-2009, 01:38 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Does this tutorial make any sense?
-
The crystal ball is in the shop, so it's hard for me to discern what is presently wrong with your code. Why not post it here?
- 09-01-2009, 04:25 PM #4
Member
- Join Date
- Sep 2009
- Posts
- 7
- Rep Power
- 0
import javax.swing.*;
import java.text.*;
public class money{
public static void main(String[]args){
DecimalFormat formatter = new DecimalFormat("#0");
String P="";
double p=0.00;
double a=0;
double b=0;
double c=0;
double d=0;
double e=0;
double f=0;
double g=0;
double h=0;
double i=0;
double j=0;
double k=0;
double l=0;
double m=0;
double n=0;
do{
P=JOptionPane.showInputDialog(null,"Enter Value:");
p=Double.parseDouble(P);
while(p>999){
a=(p-(p%1000))/1000;
{break;}}while(p>499){
b=((p-(a*1000))-(p%500))/500;
{break;
}}while(p>199){
c=((p-(a*1000))-(p%200))/200;
{break;}}
while(p>99){
d=((p-(b*500)-(c*200)))/100;
{break;}}
JOptionPane.showMessageDialog(null,"You Have\n1000= "+(formatter.format(a))+ "\n500= "+(formatter.format(b))+"\n200= "+(formatter.format(c))+"\n100= "+(formatter.format(d)));
}while(JOptionPane.showConfirmDialog(null,"Again?" )==0);
}
}
try 500 or 600
it's wrong the decimal formatter is rounding it off >.<
sadly i deleted the file with the 200 since its not getting fix,, how can u remove the decimal without rounding it off?Last edited by IWanna4get; 09-01-2009 at 04:44 PM. Reason: update :D
- 09-01-2009, 11:32 PM #5
Member
- Join Date
- Aug 2009
- Posts
- 76
- Rep Power
- 0
So is this program trying to calculate which of the 'bills' to give back as change or something?
You really should label things with readable/logical names. Using letters is bad practice, unless you are doing a simple loop and using it as an iterator or something...
- 09-02-2009, 12:52 AM #6
Member
- Join Date
- Sep 2009
- Posts
- 7
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks