| | |
help? trying to compare input with symbol.
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2004
Posts: 7
Reputation:
Solved Threads: 0
i am trying to have macromedia flash button send a double or a symbol like (+, =, &) to a java program. the java program will save the input on an arraylist. while the flash button sends doubles it simply puts them on the arraylist, but if a symbol comes in, then the items from the arraylist are removed and summed up.
so this is the code that i have. i do not want to use the showOPtionPane dialog boxes from the java library. i want jave to simply be able to receive input.
thx in advance.....
so this is the code that i have. i do not want to use the showOPtionPane dialog boxes from the java library. i want jave to simply be able to receive input.
Java Syntax (Toggle Plain Text)
import javax.swing.JOptionPane; import java.lang.*; import java.util.*; import java.io.*; public class arrayList { public static final String plus = "plus"; public static final double TAX = 0.08; public static double subTotal = 0.00; public static double total = 0.00; public static void main(String[] args) { String price = ""; // initialized the variable price to empty string ArrayList keypad = new ArrayList(); // create an arraylist and name it // keypad while (true) // continuous loop to stop when array is // empty { try // read data from console { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); //System.out.println("Enter price"); //System.out.flush(); price = in.readLine(); } catch (IOException ioe) // if error then catch error { System.out.println(ioe); } keypad.add(price); // put data read from console into stack if (price == ("+")) // if the data is a plus sign then add the items // in the stack (subtotal key) { keypad.remove(price); //remove the + sign from the stack for (int i = keypad.size() - 1; i <= 0; i--) // get all the data // from the stack and continuously add them together { keypad.get(i); // get item from stack subTotal += i; // add it to itself keypad.remove(i); // remove item from stack } System.out.println("SubTotal is " + subTotal); // print subTotal // to console }
thx in advance.....
![]() |
Similar Threads
- How to display numbers from an input file and count each one's occurence (C++)
- C++ counting problem (C++)
- HELP! Illegal Character Constant in a Console Application (C++)
- help? trying to compare input with symbol. (Java)
- help with program (C++)
- Need Help Outputting Information Using Arrays In QBasic (Legacy and Other Languages)
- How to exit without exit? (C++)
Other Threads in the Java Forum
- Previous Thread: Need Help on showInputDialog
- Next Thread: filtering bad user input
Views: 1617 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Java
6 android api apple applet application arguments array arrays automation binary bluetooth bold byte c++ chat class classes client code component coordinates database datagram doctype draw eclipse educational error event exception file fractal froglogic game givemetehcodez graphics gui helpwithhomework html ide ideas image ingres input integer internet intersect ip j2me java javaexcel javaprojects jmf jni jpanel jtextarea julia linux list loop map method methods mobile netbeans newbie nextline number object oracle pong print problem program programming project recursion recursive scanner screen sell server set size sms socket sort sql string swing test threads time transfer tree user web websites windows





