Pop from stack and store to char?

I am trying to write an infix to postfix prgm and when i compile i get:
ListOperations3.java:143: incompatible types
found : java.lang.Object
required: char
topOp = oStack.pop();
because apparently the built in stacks use generic objects as a return type and thats incompatible with char. How can i pop from the stack to a char?
Here is a method where the problem arises:
public void Parenthesis(){
char ch;
char topOp;
while(!oStack.isEmpty()){
topOp = oStack.pop();
if(ch == '(')
break;
else
postFix = postFix + ch;
}

This is one of the classes that contains the options for a menu. The other two classes dont have any real
impact on the code so I'm not gonna post them.
import java.util.*;
  import java.io.*;
  import javax.swing.*;
  import java.lang.*;
    public class ListOperations3{
      public String postFix = "";  
      public String expression = "";
      Scanner scan;
      Stack oStack = new Stack();
      char ch;
       public ListOperations3(Scanner scan){
         this.scan  = scan;
       public void menu(){
         char option;
         String message;
         int score;
         Screen scr = new Screen ();
         scr.clearscreen ();
         scr.movedown (10);
         DisplayMenu3 menu = new DisplayMenu3();
         menu.printmenu ();
         do {
            scr.movedown (2);
            scr.moveright (15);
            System.out.print ("Enter an option: 0 for Menu, Q to quit");
            message = scan.next();
            option = message.charAt(0);
            switch (option) {
               case '0':     scr.clearscreen ();
                  scr.movedown (10);
                  menu.printmenu ();
                  break;                           
               case '1': //Accept infix expression from user
                  expression = JOptionPane.showInputDialog("Please enter an expression using variables(A-Z):\t");
                  expression = expression.toUpperCase();
                  expression = expression.replaceAll(" ", "");
                  break;                           
               case '2':// Convert to postfix expression
                  scr.clearscreen ();
                  String postfix = InToPost(expression); 
               case '3': // Evaluate postfix expression
                  break;                           
               case 'q':   
                  break;
               case 'Q':  
                  break;    
               default:     scr.clearscreen ();
                  scr.movedown (10);
                  scr.moveright (15);
                  System.out.println ("Invalid option");
                  scr.movedown (5);
                  menu.printmenu ();
                  break;
            }// switch
         } // do
         while (option != 'Q'&& option != 'q');
         scr.clearscreen ();
         scr.movedown (10);
         scr.moveright (15);
         System.out.println("Thank you for using this program ");
         scr.movedown (3);
         scr.moveright (15);
         System.out.println("Have a nice day");
      } // main method             
       public String InToPost(String infix){
         for (int i = 0; i < infix.length(); i++) {
            ch = infix.charAt(i);
            switch(ch){                    
               case '+'://It's addition
                  Operator(ch, 1);
                  break;
               case '-'://It's subtraction
                  Operator(ch, 1);
                  break;                            
               case '*'://It's multiplication
                  Operator(ch, 2);
                  break;
               case '/'://It's division
                  Operator(ch, 2);
                  break;                            
               case '^'://It's exponential
                  Operator(ch, 3);
                  break;                            
               case '('://It's a left parenthesis
                  oStack.push(new Character(ch));
                  break;                            
               case ')'://It's a right parenthesis
                  Parenthesis();
                  break;                            
               default://It's an operand
                  postFix = postFix + ch;
                  break;                                    
         return postFix;
       public void Operator(char thisOp, int thisPrec){
         int topPrec;
            char topOp;
         while (!oStack.isEmpty()){
           Character c = oStack.pop();
            topOp = c.charValue();           
            if(topOp == '('){
               oStack.push(new Character(topOp));
               break;
            else {
               if(topOp == '+' || topOp == '-')
                  topPrec = 1;
               else if(topOp == '*' || topOp == '/')
                  topPrec = 2;
               else if(topOp == '^')
                  topPrec = 3;
               if(topPrec < thisPrec){
                  oStack.push(new Character(topOp));
                  break;
               else
                  postFix = postFix + topOp;
         oStack.push(new Character(topOp));   
       public void Parenthesis(){
            char topOp;
         while(!oStack.isEmpty()){
           Character c = oStack.pop();
            topOp = c.charValue();
            if(topOp == '(')
               break;
            else
               postFix = postFix + topOp;
   }// class NewBasicMenu <code class="jive-code jive-java">

Similar Messages

  • How to fetch data from XML and store it in internal table

    Hi All,
    Can anyone help me out, in fetching data from xml and store it in an internal table. Is there any standard function module is there?
    Regards,
    Karthick

    to do this you can either develop a XSLT program and use it with CALL TRNSFORMATION key word to tranform the XML into itab .
    (search the ABAP General forum, i have posted few samples)
    or simply use the following FM which converts your XML into a itab of name value pair (name would holw the element name and value would hold the value of the element) which you can then loop and read it to your itb.
    data:             xmldata type xstring .
    data: result_xml type standard table of smum_xmltb .
    data: return type standard table of bapiret2 .
    CALL FUNCTION 'SMUM_XML_PARSE'
      EXPORTING
        xml_input       = xmldata
      TABLES
        xml_table       = result_xml
        return          = return .
    Regards
    Raja

  • Is it possible to record audio/ vedio from applet and store it on server

    Pls tell me if it is possible to record audio/ vedio from applet and store it on server. I am using JMF. i am able to store audio on the same machine by making a java application but i am not able to understand how to use RTP with it to store it on server from an applet. pls help me i am in urgent need.

    If u want to capture audio/video from the client machine these are the pre-requisites
    1. u need to have JMF installed on the client :(
    one way out of this is that u bundle the library files along ur applet to the client. I am still to figure out how
    to fo that.
    2. while installation uncheck the option 'copy DLLs to system folder....' and check the option 'Allow capture
    from applets.
    3. The Applets u create must be signed, for accessing the client resources such as hard drive.
    You can then capture n save file on the client, open an inout stream out of it, open an outputstream to the server as already described above and start uploading......

  • How to pop the stack and keep track of charFlag, in C?

    /* Below is am popping the stack, which works, but it does not keep track of the charFlag variable that is pushed onto the stack. Can you help me with modifying this *char pop (stackNodePtr ptr) so when it pops the value from the stack, and keeps track of the charFlag?
    Thank you very much in advance for your assistance!!!
    Note: This posts is an offspring of my previous question: _"Why is the stack, written in C, converting + to ascii 42 ?"_. I want to thank Xnav for the excellent suggestion of including a character flag to keep track of the datatype being pushed onto the stack. Thank you etresoft for variable renaming comment.
    typedef struct stackNode {
    int value;
    int charFlag;
    struct stackNode *next;
    }stackNode;
    typedef stackNode * StackNodePtr;
    char pop( StackNodePtr *ptr )
    if( StackIsEmpty(*ptr))
    printf("
    Pop attempted, but the Stack is empty, or underflow");
    exit(2);//needed stdlib.h to work
    else
    char sTop;
    StackNodePtr old;
    if( (old = (StackNodePtr ) malloc( sizeof (StackNodePtr) )) == NULL )
    printf("
    No memory left for pop operation");
    sTop = (*ptr)->value;
    old = *ptr;
    *ptr = (*ptr)->next;
    free(old);
    return (sTop);

    //I added a global variable int gCharFlag to keep track of the popped charFlag. Will the code below work, or should I just return (*ptr)? Thank you once again!
    //struct, typedef and gCharFlag are stored inside of a .h file
    typedef struct stackNode {
    int value;
    int charFlag;
    struct stackNode *next;
    }stackNode;
    typedef stackNode * StackNodePtr;
    int gCharFlag;//global variable, which is stored inside of a .h file
    //below method is stored inside of a .c file
    char pop( StackNodePtr *ptr )
    if( StackIsEmpty(*ptr))
    printf("
    Pop attempted, but the Stack is empty, or underflow");
    exit(2);//needed stdlib.h to work
    else
    char sTop;
    StackNodePtr old;
    if( (old = (StackNodePtr ) malloc( sizeof (StackNodePtr) )) == NULL )
    printf("
    No memory left for pop operation");
    sTop = (*ptr)->value;
    gCharFlag = (*ptr)->charFlag;
    old = *ptr;
    *ptr = (*ptr)->next;
    free(old);
    return (sTop);//to return the struct node, then it would be return (*ptr), correct?

  • ? read from clob and store each line in database

    Greetings,
    i would like to read LINE BY LINE the contents of a CLOB column( which stores the contents of a plain file .txt)
    and store each line into a table.
    Is that possible?

    pollywog wrote:
    with t as (select to_clob('fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    v
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa
    fdsafdsafdafdsaffdsafdsafdsafdsafdafdafdsdsfdsa') x from dual
    select
    text
    from t
    model return updated rows
    dimension by (0 d)
    measures (dbms_lob.substr( x, 4000, 1 ) text, 0 position_of_return )  -- the position of return is where the next carriage return is
    rules iterate(100) until position_of_return[iteration_number+1] = 0
    position_of_return[iteration_number + 1] = instr(text[0],chr(10),1,iteration_number + 1),
    text[iteration_number + 1] = substr(text[0],
    position_of_return[iteration_number],
    position_of_return[iteration_number + 1] - position_of_return[iteration_number]
    Hi;
    Thank you for your kind help. The query is very fast. But i would like to ask a question about it. My CLOB contains more than 4000 characters. Is it possible to change the *1* in dbms_lob.substr( x, 4000, *1* ) to start again from where it left.
    I did that by making a pipelined function and loop ing until i get to end of clob. But is there a faster way using just sql..
    Best Regards
    Fatih
    FUNCTION get_clob_lines(cl_data CLOB) RETURN t_x_clob_table
    PIPELINED IS
    yrecords t_x_clob_record;
    CURSOR c_lines(n_start_position IN NUMBER) IS
    SELECT position_of_return
    ,text
    FROM (SELECT position_of_return
    ,text
    FROM dual model RETURN updated rows
    dimension BY(0 d)
    measures(dbms_lob.substr(cl_data, 4000, n_start_position) text, 0 position_of_return)
    rules iterate(4000) until position_of_return [ iteration_number + 1 ] = 0
    (position_of_return [ iteration_number + 1 ] = instr(text [ 0 ], chr(10), 1, iteration_number + 1),
    text [ iteration_number + 1 ] = substr(text [ 0 ],
    position_of_return [ iteration_number ] + 1, position_of_return [ iteration_number + 1 ] - (position_of_return [ iteration_number ] + 1))
    ) ccc
    WHERE ccc.position_of_return <> 0
    ORDER BY ccc.position_of_return;
    l_n_max_position NUMBER;
    l_n_start_position NUMBER;
    BEGIN
    l_n_start_position := 1;
    WHILE l_n_start_position < dbms_lob.getlength(cl_data) LOOP
    FOR r_lines IN c_lines(l_n_start_position) LOOP
    yrecords := t_x_clob_record(n_position => r_lines.position_of_return,
    v_text => r_lines.text);
    l_n_max_position := r_lines.position_of_return;
    PIPE ROW(yrecords);
    END LOOP;
    l_n_start_position := l_n_start_position + l_n_max_position;
    END LOOP;
    RETURN;
    END;

  • Read data from .xls and store it in blob

    Hi,
    I am getting the file using CLIENT_GET_FILE_NAME. I need to read the data from the .xsl file and convert it into blob. The file should not be stored in DB.
    Please help me by providing suggestions / solutions.
    Thanks.
    Edited by: tharini on 10-Aug-2010 04:16

    InoL,
    You can use an OLE Container or you can use a database stored procedure to write the file to the BLOB or extract the file from the BLOB. Then, using WebUtil you can serve the file to the the user. Of course, you would use WebUtil to allow the user to upload the document to the server so you can call the stored proc to load the file into the BLOB.
    The file should not be stored in DB.Hence my question:
    Why do you want to store the raw data from the spreadsheet in a BLOB instead of the file in a BLOB?What is the business requirement and how do you plan on using the data once it is stored in the BLOB?
    If it is a hard requirment to not store the file, then tharnini has to figure out how to take the contents read from the .xls file using WebUtil and store this in the BLOB. More importantly, how do you take the contents of the file stored in the BLOB and write it back out to a file in the same format as the original file so the user can view the information.
    I've not done this using the aforementioned method - I've not done using the OLE container either. ;-)
    Craig...
    Edited by: CraigB on Aug 10, 2010 12:49 PM

  • Download from ArchiveLink and store in AIX server

    Hi,
    Is there a way to download file from SAP ArchiveLink and store it in AIX server.
    In my case, i would like to download photo for HR module which displayed in PA20/PA30.
    Currently i use function module 'ARCHIVOBJECT_GET_CLIENT' with the following parameters
    CALL FUNCTION 'ARCHIVOBJECT_GET_CLIENT'
      EXPORTING
        archiv_doc_id = connections-arc_doc-id  "value of doc ID, I know how to get this
        archiv_id        = connections-archiv_id     "archiving ID, I also know how to get this
        path              = '/usr/sap/FSQ/pic/0012345.jpg'          "I want to store in this AIX folder
        doc_type       = 'JPG'
    If I test path = 'C:/photo/0012345.jpg' everything works perferctly, but if I change to '/usr/sap/FSQ/pic/0012345.jpg'  and I check on AIX folder, there is nothing there.
    I have given full permission for sapusr ID and ReadWrite permission for this folder.
    Is there any other FM for my requirement or any advice?
    Thanks.
    Best regards,
    Bernard

    hi
    use SCMS_HTTP_GET_FILE
    Regards
    sameer.

  • How do I upload fotos from iPhone and store on computer?

    I need to know how to upload fotos from my fone and store on my computer

    Use PhotoStream
    Or
    Sync using iTunes
    Or
    Sync using a USB cable connection
    LN

  • How to zip up data from database and store as blob

    I would like to know how best to zip up retrieved data from the database and store it as a blob back on to the database.
    Thanks.

    Hi Cris,
    Add-on to wat santosh has pointed to:
    Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
    (Or) If you have implemented your logic to get Database records below Blog should guide you in opening an excel with ur records.
    Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
    Regards,
    N.

  • HT201318 Does I cloud remove pictures from device and store them some where

    Does I cloud removes pictures after a period of time and store them someplace that I can go and find them?

    I have the same problem and I'm not sure this addresses it.  I want to subscribe to iTunes match using my Mac; the intention being that I can then remove all the subset of my tunes from the ipad mini, and when travelling listen to music on the iPad mini via iTunes Match.
    So the question still remains, does the music stored on my iPad mini get automatically removed when i subscribe to iTunes Match, or do I have to remove it??
    Also, my iPad mini is showing that 1.8GB of storage is taken up by music at the moment, will all of this be freed if I subscribe to iTunes match and delete the music (irrespective of whether this is done manually or via an automatic delete).
    Thank you

  • How to query data from database and store it into Managed Bean ?

    Hi all,
    In our application we have requirement to store information within Managed Bean to be accessed by ADF pages.
    The information is stored in database tables.
    The question is :
    What is the efficient / recommended way to do that ?
    I do not use apps module to query the data because the information is required in View layer not the model layer
    Thank you for your help,
    xtanto

    Xtanto,
    if the information is stored in the database then the question is if there is a database connect open already. If yes, then why not using this connection to query for the data you want to access and store. Alternatively you can directly open a JDBC connection in a managed bean or access an EJB session bean. However, this comes with the price of an extra database connection.
    Make sure the managed bean is in session scope if you want to share the information without re-fetching it
    Frank

  • HT1918 i need to remove my credit card info its been declined now im blocked from itunes and store need help

    my credit card is being declined and now blocked me out of itunes and store yet wont let me update my card info what do i do???

    We have the same problem. it looks like uyou will have to cancel the card.( really inconvenient) I know. then we just used  itunes prepaid cards. we feel a little smarter doing it this way.

  • Purchased itunes store films disappearing from library and store.

    I purchased 'Home Alone' last Xmas and now it has gone from my itunes library and no longer available to download in the UK store, does anyone know why?

    This seems to be an issue with iOS 8.1.1.  Contact iTunes Support as you shouldn't have to pay for ringtones you can't use.
    http://www.apple.com/support/itunes/contact/

  • [webdynpro] How to get the data from database and store in Excel sheet

    Hi All-
    I am developing an application in Webdynpro and I need to provide a URL ( link ) which if clicked , need to collect the data from Database ( SQL Server ) and puts in an Excel Sheet corresponding fields and opens the sheet.....
    Please look into this issue and help me out......
    Regards,
    Cris

    Hi Cris,
    Add-on to wat santosh has pointed to:
    Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
    (Or) If you have implemented your logic to get Database records below Blog should guide you in opening an excel with ur records.
    Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
    Regards,
    N.

  • How to get the document no. from BAPI_GOODSMVT_CREATE and store in ztable?

    Hi All,
    I am using BAPI_GOODSMVT_CREATE to create goods movement .its sucessfully excuted.
    Now I want to store Document Number in Ztable which is getting from MB11(Goods movment create).
    Plz suggest how i proceed?
    Thanks in Advance...
    Regards
    Steve

    The following Exporting Parameter(s) will give you Document Number & Document Year.
    GOODSMVT_HEADRET (Doc. No + Doc. Year)
    MATERIALDOCUMENT
    MATDOCUMENTYEAR
    Regards,
    Ramki.

Maybe you are looking for

  • Loops to a PC

    I have garageband on my Ipad and would like to import new loops, but I only have a PC.  Is this possible and how?

  • Mail app not connecting to gmail account

    Hi So I have 2 gmail accounts where our company domain uses gmail for its email service. Mail was working fine on both the accounts till last week. I had configured both the gmail accounts very easily by just selecting Google on the Mail App on my Ma

  • Purchase Ledger Chile - S_ALR_87099947

    Hi, I'am having a problem when i´m generating the reporting (Purchase Ledger - Chile), because it appears the reference transaction CAJO when is associated as a funds constitution/reposition in FBCJ. I think that is not suppose to appear. It should o

  • Why is compressor 4.1.1 only giving me mp4s with 128kbps audio?

    Hi everyone, I'm using the mp4 encoders a lot in Compressor. It recently was updated to 4.1.1 and the OS to Mavericks 10.9.2. The bitrate slider in the settings has absolutely no effect on the resulting file regardless of the source file and the sett

  • Nokia 5200 bible Application

    i cant get a compactable Bible Software for my phone. can somebody help?