944,156 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1834
  • Java RSS
Nov 2nd, 2004
0

help? trying to compare input with symbol.

Expand Post »
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.

Java Syntax (Toggle Plain Text)
  1. import javax.swing.JOptionPane;
  2. import java.lang.*;
  3. import java.util.*;
  4. import java.io.*;
  5.  
  6. public class arrayList
  7. {
  8. public static final String plus = "plus";
  9. public static final double TAX = 0.08;
  10. public static double subTotal = 0.00;
  11. public static double total = 0.00;
  12.  
  13. public static void main(String[] args)
  14. {
  15. String price = ""; // initialized the variable price to empty string
  16.  
  17. ArrayList keypad = new ArrayList(); // create an arraylist and name it
  18. // keypad
  19.  
  20. while (true) // continuous loop to stop when array is
  21. // empty
  22. {
  23. try // read data from console
  24. {
  25. BufferedReader in =
  26. new BufferedReader(new InputStreamReader(System.in));
  27. //System.out.println("Enter price");
  28. //System.out.flush();
  29. price = in.readLine();
  30. }
  31.  
  32. catch (IOException ioe) // if error then catch error
  33. {
  34. System.out.println(ioe);
  35. }
  36.  
  37. keypad.add(price); // put data read from console into stack
  38.  
  39. if (price == ("+")) // if the data is a plus sign then add the items
  40. // in the stack (subtotal key)
  41. {
  42. keypad.remove(price); //remove the + sign from the stack
  43.  
  44. for (int i = keypad.size() - 1; i <= 0; i--) // get all the data
  45. // from the stack and continuously add them together
  46. {
  47. keypad.get(i); // get item from stack
  48. subTotal += i; // add it to itself
  49. keypad.remove(i); // remove item from stack
  50. }
  51.  
  52. System.out.println("SubTotal is " + subTotal); // print subTotal
  53. // to console
  54. }

thx in advance.....
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ra2833 is offline Offline
7 posts
since Nov 2004
Nov 2nd, 2004
0

Re: help? trying to compare input with symbol.

moderator please retire this thread....

thx
ra2833
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ra2833 is offline Offline
7 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Need Help on showInputDialog
Next Thread in Java Forum Timeline: filtering bad user input





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC