help? trying to compare input with symbol.

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2004
Posts: 7
Reputation: ra2833 is an unknown quantity at this point 
Solved Threads: 0
ra2833 ra2833 is offline Offline
Newbie Poster

help? trying to compare input with symbol.

 
0
  #1
Nov 2nd, 2004
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.

  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.....
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 7
Reputation: ra2833 is an unknown quantity at this point 
Solved Threads: 0
ra2833 ra2833 is offline Offline
Newbie Poster

Re: help? trying to compare input with symbol.

 
0
  #2
Nov 2nd, 2004
moderator please retire this thread....

thx
ra2833
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1617 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC