-
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 -.-
-
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?
-
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?
-
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...
-
This program is a money denominator ex:
i input 5600
output: you have
1000=5
500=6
200=0
100=1
in short it shows what the value is made of (the value is currency :p)