Pseudocode help

PSEUDOCODE... i got the following pseudocode:
This is what iv got done but its not looking correct:
apart from the indentations could someone help me edit it appropriately?
RoomTest
driver CLASS
double roomStore
Set valid to false
WHILE (not valid)
TRY
New DecimalFormat(“0.00”)
CREATE rectangle1
Prompt operator for roomW
Parse roomW to roomStore
rectangle1.setWidth(roomStore)
Prompt operator for roomL
Parse roomL to roomStore
rectangle1.setLength(roomStore)
CREATE rectangle2
Prompt operator for roomW
Parse roomW to roomStore
rectangle1.setWidth(roomStore)
Prompt operator for roomL
Parse roomL to roomStore
rectangle1.setLength(roomStore)
Print “Room Area Calculator Program”
Print “****************************”
Print rectangle1 width
Print rectangle1 length
Print rectangle2 width
Print rectangle2 length
Print “Room1”
Print rectangle1 width, length, area
Print “Room2”
Print rectangle2 width, length, area
Print "************End of program************"
Valid = true
CATCH (NumberFormatException)
               Display error message
          END
END
END
Room
PRIVATE variables width and length
Set width to 0
Set length to 0
VOID setMethod
Set width to objectWidth
END METHOD
VOID setMethod
Set length to objectLength
END METHOD
DOUBLE getMethod
RETURN width
END METHOD
DOUBLE getMethod
RETURN length
END METHOD
DOUBLE findAreaMethod
Set roomArea to 0
roomArea = width * length
return roomArea
END METHOD
END
Could someone is possible maybe edit it appropriately please?
Thanks

Why not continue in this thread:
http://forum.java.sun.com/thread.jspa?threadID=5120469
I asked you a question there.

Similar Messages

  • * pseudocode help if possible!!

    Hi.
    I could really use your help on this.
    TY!
    http://i13.photobucket.com/albums/a267/spauldingchris/File0001.jpg

    I don't even know why they offer Java courses at colleges. Students see it and think it will be like other classes (something that they have a chance in hell of understanding let alone passing).
    I think Java 101 is the "flunk course" for computer science majors.
    Like calculus is for business majors.
    That way they know everyone will not pass and it will lend credability (in theory) to the degree.

  • Help with pseudocode

    hi. can someone helpe me translate this pseudocode please:
    for each vertex v
            set kv to false
            set pv to unknown (or none, if v is the start vertex)
            set dv to infinity (or 0, if v is the start vertex)
        PriorityQueue pq = new PriorityQueue()
        pq.enqueue(start vertex, 0)
        while (!pq.isEmpty())
            vertex v = pq.dequeueMin();
            if (kv is false)
                kv = true
                for each vertex w such that edge v -> w exists
                    if (dw > dv + C(v, w))
                        dw = dv + C(v, w)
                        pw = v
                        pq.enqueue(w, dw)
        }

    Care to tell me what's wrong with this.
    I was showing him what a for loop looks like and what
    a for each looks like.Norweed,
    Your code snippet is liable to cause far more confusion than clarity, for the following reasons:
    The OP's pseudocode references "v" as an individual vector; your suggested code uses "v" as the collection of vectors.
    The OP makes no mention of his collection of vectors being stored in an ArrayList; your code could be interpretted as "one must use an ArrayList in order to do a for loop".
    Your ArrayList is not initialized, yet you make no "do initialization stuff" indication between its declaration and usage.
    ArrayList does not have a component "size".
    The usage of an index, "i", is extraneous as the pseudocode has no requirements for tracking a numeric index as the code loops through the collection of vectors. I find your later comment "I was showing him what a ... for each looks like." puzzling. Indeed, a for each style loop would have been appropriate, but it is missing from your post.
    In short, to someone who has expressed confusion over how to wrie a for-loop, I cannot fathom how the following four lines of text would do anything but confuse that person even further:
    ArrayList v;
    for(int i=0; i<v.size; i++){
    do stuff;
    }>
    Message was edited by:
    kevkirk

  • Need help in building search query

    Guys ..
    Problem Description:
    I have a huge table that is indexed using CONTEXT.
    I want to write a search query that considers the following:
    1. number of keywords match
    2. takes care of spelling mistakes, synonyms and acronyms
    3. proximity - the keywords should not be too far of each other.
    e.g. I have this phrase: "Horizontal Stabilizer Trim Brake"
    I was thinking of writing a query like:
    SELECT SCORE(1) SCORE,
    TEXT text
    FROM MY_TABLE
    WHERE CONTAINS(TEXT, '(Horz | Horizontal) ACCUM (Stab | Stabilier) ACCUM Trim ACCUM (Brk | Break)', 1) >= 0
    ORDER BY SCORE DESC
    The results doesnt look satisfactory. I have not used "near" operator as i dont know how to use it.
    Please help me as I am very much new to Oracle Text.
    -G

    Well, I'm not going to write the function for you, but we can at least talk through a general strategy.
    A lot depends on how you help your users on the front end -- for example, if they're searching a technical document, you may want to return results that aren't perfect matches but you do want to make sure the user picks 'mandatory' and 'useful' keywords in a way that lets you figure out which ones are really important. On the other hand, if you're google and have to handle queries like 'horizontal stabilizer trim brake' and 'were Pete and Jenny in the break room' then you run the risk of spending too much time looking for interesting words, almost doing a full-text search on the query trying to derive meaning.
    So I'm going to presume that you have some control over what/how the users generate their searches so that finding keywords isn't the issue.
    The plan will be to parse the query a bit to find the interesting words, clean them up, and weigh their importance, then use transformed data to build the query template to score various combinations.
    So here's some pseudocode for the function:
    function parse_query(pQueryWords in clob) returns clob as
    begin
        generate_token_list (); -- split the query into a set of individual tokens/words
        for each token in token_list
            if it's a mandatory word then accumtokenlist := accumtokenlist || ' ' || token ||'*10' -- weigh the presence of the token strongly
            if it's a useful word then accumtokenlist := accumtokenlist || ' ' || token ||'*5' -- domain-specific words are also important
            if it's a stopword or reserved word, then do not add it to the list
            if it's not on my lists, then accumtokenlist := accumtokenlist || ' ' || token
                                         and normaltokenlist := normaltokenlist ||' ' || token
        end;
        --so now, we have two lists, one for NEAR and one for ACCUM
        now build the guts of the template
            querytemplate := querytemplate || '<seq> || normaltokenlist || '</seq>';
            querytemplate := querytemplate || '<seq> || replace (accumtokenlist, ' ',' ACCUM ') || '</seq>';
            querytemplate := querytemplate || '<seq>$' || replace(normaltokenlist,' ','$') || '</seq>';
            querytemplate := querytemplate || '<seq>? || replace(replace(accumtokenlist,' ',' ?'),' ', ' accum ') || </seq>';  -- first fuzzy the words, then accum
            querytemplate := querytemplate || '<seq>? || replace(replace(normaltokenlist,' ',' ?'),' ', ' near ') || </seq>';  -- first fuzzy the words, then near
        return querytemplate
    end;So, with a 'cooked' query text that is template-friendly, all we need to do is apply a template that is aware of your inputs:
    query_Template_string := '
    <query>
       <textquery lang="ENGLISH" grammar="CONTEXT"> horizontal stabilizer*5 trim brake*10
         <progression> '
    || parse_query('horizontal stabilizer trim brake')  ||
    '     </progression>
       </textquery>
      <score datatype="INTEGER" algorithm="COUNT"/>'
    </query>So that's an example of one approach.

  • Is it possible to automate/script this catalogue ? - please help!

    Hey,
    I was researching a lot already...
    but still cannot answer the simple question whether or not it is possible, what I want to accomplish here
    Oook, please have a look at it and let me know if its possible and if so, which route would be wise to take..
    There are two slightly different types of catalogues.
    TYPE A
    products are more or less randomly placed on the spread, each one has its related text frame (ItemNumber, Name, Description, Price)
    This catalogue type would only have 3 double spreads like the one below.
    The text is provided in an Excel spreadsheet and changes throughout the process
    http://i.imgur.com/Nckpm.jpg
    TYPE B
    similar arrangement of products, but up to 50 pages.
    Also the product description is at the bottom of each page for each group of products on that page. and as you can see its quite heavily formatted and has a few en's and em's as well
    so, only the positionNumber and the price is placed next to the products. the bottom text comes originally in an excel spreadsheet as well
    (would be nice if that additional price could also update with changes in the excel document)
    http://i.imgur.com/UoD5z.jpg
    I was also testing trial versions of Indesign Plugins like InCatalog or InData..
    probably too stupid to get them to work, or maybe I need custom scripting — would, in that case, javascript be a good idea?
    I would tremendously appriciate if you could point me in the right direction or help me break it down in pseudocode or sthg..
    couldnt find any other project similar to this one, but maybe you do know one
    THX in advance!!

    Data Merge, third party plug-ins and XML all need some kind of structure to a document before anything can really be automated. The samples, while they have a content structure (that is, a picture has a description, price and name) it doesn't have a predetermined position on the page. 
    Assuming the excel file also has the picture name in one of the fields, data merge could be used to call in all the data and merged via multiple record layout into a new indesign file, but it wouldn't appear as the final layouts above... instead the file would appear as a grid. From here, the pictures and their captions need to be moved to their appropriate positions.
    I've been umming and ahhing over what to write in the post but ultimately there is no turn-key solution. The best I can think of would still involve running a script on each page and then processing the result of that manually. Automated catalogues are ideal for the likes of phone directories, parts catalogues or school yearbook pictures. this catalogue is outside of those specs and I can't see a way of automating this... as a turn-key solution. I would be interested to see what other posters have to say but I think this is a bridge too far to automate.
    In terms of what may make the job easier, try these two links though:
    http://ajarproductions.com/blog/2008/11/28/merge-textframes-extension-for-adobe-indesign/ (a script for merging loose text frames into one big textframe)
    http://tomaxxi.com/2011/04/mastering-live-captions/ (for using the captions feature to do lots of the hard work of presenting the data under a picture)
    colly

  • Urgent Help with a my Cheap Greek Hotel!

    Thanks for your help with the pseudocode. I have got many errors with this program in the funtions. The code is below. Is there someone who can help me get my head around them?
    import Date;
    import Money;
    public class Hotel {
        private Room[] rooms = new Room[12];
        public Hotel() {
             for(int i = 0; i<rooms.length; i++){
                 rooms[i] = new Room(i+1,20);
        public static void main (String[]args)
         // public void bookIn(String guest, Date today)
         public void bookIn(String guest, Date today, int roomNumber)
            if (roomNumber < 1 || roomNumber > rooms.length){
                throw new Exception("Room numbers must be within 1-" + rooms.length);
            if (rooms[roomNumber-1].getRoomHolder() !=null){
                throw new Exception("Room " + roomNumber + " not available.");
            rooms[roomNumber-1].setRoomHolder(guest);
            rooms[roomNumber-1].setBookedIn(today);
         // fn to put a guest in ata a specified date
         public void bookOut (Date checkedIn, Date checkedOut)
            //In the date class you can probably check the Calendar class to find
            //out the syntax for subtracting dates
            int nightsStayed = checkedOut - checkedIn;
            //Now I'd have an array of Guest
            //objects, where the room number = the position in the
            //array.  When a guest checks in, you can set whatever
            //info. you need (check in date, guest name, etc.) and
              //set it back to null when a guest checks out.
              new Room[12][roomNumber] = null;
              //calculate the fee
            double price = getFee(nightsStayed);
            System.out.println("You owe: "+price);
         // public double bookOut(Date currentdate)
        }//end method
        public double bookOut (Date currentdate)
        // fn to empty the room and may be calculate & return the value of the bill
        public double getFee(int nightsStayed)
            double fee = (nightlyFee*nightsStayed);
            return fee;
            //end method
            //end class
    }The errors in this program are listed below`
    T:\Year 1\Programming Workshop\Assignment2\Assignment2\Hotel.java:31: cannot resolve symbol
    symbol  : method setRoomHolder  (java.lang.String)
    location: class Room
            rooms[RoomNumber-1].setRoomHolder(guest);
                 ^
    T:\Year 1\Programming Workshop\Assignment2\Assignment2\Hotel.java:32: cannot resolve symbol
    symbol  : method setBookedIn  (Date)
    location: class Room
            rooms[RoomNumber-1].setBookedIn(today);
                 ^
    T:\Year 1\Programming Workshop\Assignment2\Assignment2\Hotel.java:40: operator - cannot be applied to Date,Date
            int nightsStayed = checkedOut - checkedIn;
                                          ^
    T:\Year 1\Programming Workshop\Assignment2\Assignment2\Hotel.java:46: cannot resolve symbol
    symbol  : variable RoomNumber 
    location: class Hotel
              new Room[12][RoomNumber] = null;
                                 ^
    T:\Year 1\Programming Workshop\Assignment2\Assignment2\Hotel.java:46: unexpected type
    required: variable
    found   : value
              new Room[12][RoomNumber] = null;
                    ^
    T:\Year 1\Programming Workshop\Assignment2\Assignment2\Hotel.java:59: cannot resolve symbol
    symbol  : variable nightlyFee 
    location: class Hotel
            double fee = (nightlyFee*nightsStayed);
                          ^
    T:\Year 1\Programming Workshop\Assignment2\Assignment2\Room.java:36: cannot return a value from method whose result type is void
            return bookedIn;
                   ^
    7 errors
    *** Compiler reported errorsIs there anyone who can transfer my pseudocode into language specific java? I really need some help. Thanks.

    Thanks for your Help regarding methods. You managed to help me correct two errors. Which means i know have six. Thanks ever so much. The method setRoom Holder has been recognised aswell as the method setBookedIn.
    What did you mean by "I cannot use minus operators on dates?" Is there any other way that I can code this function so that it is acceptable?
    int nightsStayed = bookedOut - bookedIn;
    Can you help me code these last four functions please? Then my program will have no errors. I have to get rid of six.
    // public void bookIn(String guest, Date today)
         public void bookIn(String guest, Date today, int RoomNumber)
            if (RoomNumber < 1 || RoomNumber > rooms.length){
                throw new Exception("Room numbers must be within 1-" + rooms.length);
            if (rooms[RoomNumber-1].getRoomHolder() !=null){
                throw new Exception("Room " + RoomNumber + " not available.");
            rooms[RoomNumber-1].setRoomHolder(guest);
            rooms[RoomNumber-1].setBookedIn(today);
         // fn to put a guest in ata a specified date
         public void bookOut (Date bookedIn, Date bookedOut)
            //In the date class you can probably check the Calendar class to find
            //out the syntax for subtracting dates
            int nightsStayed = bookedOut - bookedIn;
            //Now I'd have an array of Guest
            //objects, where the room number = the position in the
            //array.  When a guest checks in, you can set whatever
            //info. you need (check in date, guest name, etc.) and
              //set it back to null when a guest checks out.
              new Room[12][RoomNumber] = null;
              //calculate the fee
            double price = getFee(nightsStayed);
            DerbyIO.getString("You owe: "+price);
         // public double bookOut(Date currentdate)
        }//end method
        public double bookOut (Date currentdate)
        // fn to empty the room and may be calculate & return the value of the bill
        public double getFee(int nightsStayed)
            double fee = (nightlyFee*nightsStayed);
            return fee;
            //end method
            //end class
    }

  • Help with Threads in java...

    Hi all,
    the problem it's the following:
    i got a program that update a sql server table. So i want, at the same time, run this program many times, say 10 for example, to do it that faster.
    But i only want 10 subprograms at the same time. So i got to use wait() and others method's, rigth?
    I'm not shure about this, because a never use threads.
    So any help, code or "pseudocode" will be very appreciated.
    Thanks in advance
    A. Santos

    Hi santhos,
    If u use 10 threads to read the sql table, then
    ur program will lose the sequence. If u have a idea
    to split the program then u can use threads.
    Regards,
    Palaniyappan

  • Need help on this plz.

    I would like to write a program for a supermarket loyalty card system. The program should have 2 customers and 2 gifts on offer. The customer details and the gift details can be hard coded.
    When the program starts the user should be shown a menu which will have options to
    view all customer details
    add points for a customer
    buy a gift
    When the user chooses to buy a gift ro to add points, any changes made to the customers' points must be done using methods. Adding or buying gifts should be done using customer id's and gift id's.
    The user must be able to see the altered points.
    I WILL APPRECIATE IF I COULD GET HELP EVEN FOR PSEUDOCODE.

    Hi,
    In order to implement your requirements, the best way would be using JSP(JavaServerPage) and SQL. Before writing code, you need to prepare, Ant, Tomcat, JavaServlet, MySQL and JDBC package. There are several books available to achieve your requirements. I think your requirements is bigger than you expect. This page is also written with JSP.
    Good luck for your program!!!

  • JCheckBox/Action Listener help

    Hey
    I'm trying to make an applet with two tabs, a PurchasePanel and a StorePanel, and have data altered in one of them affect the data in the other. On the StorePanel, the data is input infields and through a ButtonListener command it is stored as both a String in a text field on the StorePanel, and as a check box on the PurchasePanel. Now, from the PurchasePanel I need to make an ActionListener function that when the CheckBoxes are pressed, some data is added to another textfield, and when it is unchecked the data is removed. I'm not sure I implemented the actionlistener correctly as the buttonlistener and the actionlistener commands aren't recognizing variables from each other. Any help is appreciated.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.awt.Container;
    import java.text.*;
    public class StorePanel extends JPanel
    private ArrayList compList;
    private PurchasePanel purchasePanel;
    private JLabel brandName, price, memory, cpuType, cpuSpeed, info;
    private JTextArea cpuInfo;
    private JTextField BTL, PTL, MTL, TTL, STL;
    private JPanel smallPanel, leftPanel, rightPanel, wholePanel;
    private JScrollPane scrollBox;
    public int counter = 0;
    public StorePanel(ArrayList compList, PurchasePanel pPanel)
    this.compList = compList;
    this.purchasePanel = pPanel;
    brandName = new JLabel("Brand Name ");
    price = new JLabel("Price");
    memory = new JLabel("Memory");
    cpuType = new JLabel("CPU Type");
    cpuSpeed = new JLabel("CPU Speed");
    BTL = new JTextField();
    PTL = new JTextField();
    MTL = new JTextField();
    TTL = new JTextField();
    STL = new JTextField();
    JPanel smallPanel = new JPanel();
    smallPanel.setLayout(new GridLayout(5,2));
    smallPanel.add(brandName);
    smallPanel.add(BTL);
    smallPanel.add(price);
    smallPanel.add(PTL);
    smallPanel.add(memory);
    smallPanel.add(MTL);
    smallPanel.add(cpuType);
    smallPanel.add(TTL);
    smallPanel.add(cpuSpeed);
    smallPanel.add(STL);
    // organize components here
    // here is an example
    JButton button1 = new JButton("Store");
    button1.setSize(1,1);
    button1.addActionListener(new ButtonListener());
    info = new JLabel("INFORMATION", SwingConstants.CENTER);
    leftPanel = new JPanel();
    leftPanel.setLayout(new BorderLayout());
    leftPanel.add(info,BorderLayout.NORTH);
    leftPanel.add(smallPanel,BorderLayout.CENTER);
    leftPanel.add(button1,BorderLayout.SOUTH);
    cpuInfo = new JTextArea("No Computer",19,27);
    scrollBox = new JScrollPane(cpuInfo);
    rightPanel = new JPanel();
    rightPanel.add(scrollBox);
    wholePanel = new JPanel();
    wholePanel.setLayout(new BorderLayout());
    wholePanel.add(leftPanel,BorderLayout.WEST);
    wholePanel.add(rightPanel,BorderLayout.EAST);
    this.add(wholePanel);
    private class ButtonListener implements ActionListener
         public void actionPerformed(ActionEvent event)
              String BN = BTL.getText();
              String P = PTL.getText();
              String M = MTL.getText();
              String CT = TTL.getText();
              String CS = STL.getText();
              String error = "";
              String enter = "";
              String computerString = "";
              int speed = 0;
              int memory = 0;
              double price = 0;
              String status = "Yes";
              String bPrice = "";
              JCheckBox computer;
              try
                   speed = Integer.parseInt(CS);
                   memory = Integer.parseInt(M);
                   price = Double.parseDouble(P);
              catch (NumberFormatException exception)
                   info.setText("Enter a number for Price, Memory, or Speed.");
                   info.setForeground(Color.red);
                   status = "No";
              if(BN.length() == 0 || P.length() == 0 || M.length() == 0 || CT.length() == 0 || CS.length() == 0)
                   error = "Please Enter All Fields.";
                   status = "Empty";
              if(status == "Yes" || status == "Empty")
              if(error == "Please Enter All Fields.")
                   info.setText(error);
                   info.setForeground(Color.red);
              else
                   DecimalFormat myFormatter = new DecimalFormat("0,000.00");
                   bPrice = myFormatter.format(price);
                   if(counter == 0)
                        cpuInfo.replaceRange("",0,11);
                   enter = "\nBrandName:\t\t" + BN + "\nCPU:\t\t" + CT + "," + speed
                                  + "HZ\nMemory:\t\t" + memory + "M\nprice:\t\t$" + bPrice + "\n";
                   info.setText("Computer Added.");
                   info.setForeground(Color.red);
                   cpuInfo.append(enter);
                   counter ++;
                   computer = new JCheckBox("BrandName:"+BN+"CPU:"+CT+","+speed+"HZMemory:"+memory+"Mprice:$"+bPrice);
                   computer.addItemListener(new PurchasePanel.CheckBoxListener());
                   purchasePanel.leftPane.add(computer);
                   compList.add(computer);
    public class PurchasePanel extends JPanel
    private ArrayList compList;
    private JLabel CTP, Filler;
    private JTextArea totalPrice;
    protected JPanel rightPane, leftPane;
    protected JSplitPane wholePane;
    private JScrollPane scrollPane;
    private JCheckBox checked;
    private double TP = 0.00;
    public PurchasePanel(ArrayList compList)
         this.compList = compList;
         // organize components for purchase panel
         CTP = new JLabel("Current Total Purchase");
         Filler = new JLabel(" ");
    totalPrice = new JTextArea("$" + TP,18,22);
    scrollPane = new JScrollPane(totalPrice);
         rightPane = new JPanel();
         rightPane.setLayout(new BorderLayout());
    rightPane.add(CTP, BorderLayout.CENTER);
         rightPane.add(scrollPane, BorderLayout.SOUTH);
         leftPane = new JPanel();
         leftPane.setLayout(new BoxLayout(leftPane, BoxLayout.Y_AXIS));
         leftPane.setSize(800,700);
         leftPane.add(Filler);
         wholePane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPane, rightPane);
         this.add(wholePane);
    private class CheckBoxListener implements ItemListener
         public void itemStateChanged(ItemEvent event)
                   if(StorePanel.ButtonListener.computer.getStateChange() == ItemEvent.SELECTED)
                        TP = TP + 10.05;
    public class Assignment6 extends JApplet
    private int APPLET_WIDTH = 650, APPLET_HEIGHT = 350;
    private JTabbedPane tPane;
    private StorePanel storePanel;
    private PurchasePanel purchasePanel;
    private ArrayList computerList;
    //The method init initializes the Applet with a Pane with two tabs
    public void init()
         //list of computers to be used in every panel
         computerList = new ArrayList();
         //customer purchase panel uses the list of computers
         purchasePanel = new PurchasePanel(computerList);
         //store inventory panel uses the list of computers and also
         //established a connection with purchasePanel
    storePanel = new StorePanel(computerList, purchasePanel);
    //create a tabbed pane with two tabs
    tPane = new JTabbedPane();
    tPane.addTab("Store Inventory", storePanel);
    tPane.addTab("Customer Purchase", purchasePanel);
    getContentPane().add(tPane);
    setSize (APPLET_WIDTH, APPLET_HEIGHT); //set Applet size
    }

    If you pass along references to the appropriate panel to the Listeners, then they can update the right thing accordingly eg.
    // To enable the StorePanel to add/erase data from a textfield by listening to a checkbox in the PurchasePanel class
    // PurchasePanel class
    checked.addItemListener(new CheckBoxListener(storePanel));
    // CheckBoxListener class
    public void itemStateChanged(ItemEvent e) {
        // When checkbox checked
        if(checked)
            storePanel.writeToTextField("blahblah");
        else
            storePanel.writeToTextField("");
    }That was pseudocode of course! If you need the PurchasePanel to listen to the button in the StorePanel, you need to do the reverse.

  • Need urgent help in Real Time scheduling algorithm implementation

    I am new to Java Real Time programming. I have faced a problem which is stated below:
    Declare tasks
    for
    if it is schedulable then run the task
    otherwise it is not schedulable
    for
    check priority with respect to deadline.
    select highest priority task
    for
    start higest priority task
    if the task is preemtable
    then switch lowest priority task to highest priority task and stop the lowest priority task
    after completion higest priority task, lowest priority task complete the rest of the work.
    this is actually a pseudocode for real time dynamic scheduling ( rate monotonic scheduling). can anyone please help me develop the code?

    PrinceOfLight wrote:
    I am new to Java Real Time programming.
    this is actually a pseudocode for real time dynamic scheduling Define "real-time" in your context. Most people who use the term don't use it correctly. If you truly mean "real-time," then you'll need real-time Java running on a real-time OS.
    can anyone please help me develop the code?What specific problems are you having? If you have no clue where to start, this site is not a good resource.

  • ABAP Help on Update Rule Needed

    Hello.  I am trying to write a routine on an key figure in an update rule.  Basically, I am trying to load a custom key figure with either a 1 or a 0. 
    Here is the pseudocode:
    IF
    (((GI_DATE - ACT_GI_DTE) < 0) OR
      ((GI_DATE - ACT_GI_DTE) > 3)
    THEN
        NEW_KEY_FIGURE = 1
    ELSE
        NEW_KEY_FIGURE = 0
    ENDIF.
    Here is the code I currently have in the routine.  Any ideas on where I am going wrong here?  I am not an ABAP developer so please keep this in mind when responding.
    result value of the routine
      CLEAR RESULT.
    if the returncode is not equal zero, the result will not be updated
      IF COMM_STRUCTURE-GI_DATE - COMM_STRUCTURE-ACT_GI_DTE < 0 OR
         COMM_STRUCTURE-GI_DATE - COMM_STRUCTURE-ACT_GI_DTE > 3.
         COMM_STRUCTURE-NEW_KEY_FIGURE = 1.
      ELSE.
         COMM_STRUCTURE-NEW_KEY_FIGURE = 0.
      ENDIF.
      RESULT = COMM_STRUCTURE-NEW_KEY_FIGURE.
      RETURNCODE = 0.
    if abort is not equal zero, the update process will be canceled
      ABORT = 0.
    Thanks for any help you can give.

    Hi,
    I think you can not put "-" in if command, so code should be like this:
    data: datediff type n.
    result value of the routine
    CLEAR RESULT.
    clear datediff.
    detediff = COMM_STRUCTURE-GI_DATE - COMM_STRUCTURE-ACT_GI_DTE.
    IF datediff < 0 OR datediff > 3.
    Result = 1.
    ELSE.
    Result = 0.
    ENDIF.
    RETURNCODE = 0.
    if abort is not equal zero, the update process will be canceled
    ABORT = 0.
    Regards,
    Andrzej

  • I am facing syntactical error, please help

    Hi All,
    Please help me.
    I am facing syntactical error for the below mentioned code, please help me to get rid of it.
    I want to fetch the record set in cursor loop it to process one by one inside the loop - for every record - i need to fetch a record set and process it
    pseudocode will be like
    cursor c1 - select * from table
    for rec from c1
    loop
    create cursor c2 - select * form table where value = rec.value
    for rec2 from c2
    loop
    process record
    end loop
    loop end
    The exact code is
    DECLARE
    QNTY_REQ INT := 0;
    QNTY_ALLOCATED INT :=0;
    FGONHAND_CNT INT := 0;
    varINONHAND_CNT INT := 0;
    FGONHAND_QTY INT := 0;
    varINONHAND_QTY INT := 0;
    varORGANIZATION_ID INT :=166;
    varAFM_IN_TYPE_SUBINV VARCHAR2(500) :='-';
    CURSOR C1 IS
    SELECT * FROM
    (SELECT OH.ORDER_NUMBER,
    CONCAT(SUBSTR(OL.ORDERED_ITEM,0,(LENGTH(OL.ORDERED_ITEM)- 2 )),'IN') INITEM,
    (SELECT INVENTORY_ITEM_ID FROM MTL_SYSTEM_ITEMS WHERE ORGANIZATION_ID = 85
                   AND SEGMENT1 = CONCAT(SUBSTR(OL.ORDERED_ITEM,0,(LENGTH(OL.ORDERED_ITEM)- 2 )),'IN')) IN_INVENTORY_ITEM_ID,
    OL.ORDERED_ITEM,
    OL.ORDERED_QUANTITY,
    OL.INVENTORY_ITEM_ID FG_INVENTORY_ITEM_ID,
    OL.SUBINVENTORY FG_SUBINVENTORY
    FROM OE_ORDER_HEADERS_ALL OH , OE_ORDER_LINES_ALL OL
    WHERE OH.HEADER_ID = OL.HEADER_ID
    AND OH.ORG_ID = 146
    AND OH.ORDER_NUMBER = 250300149
    AND OL.SHIP_FROM_ORG_ID = varORGANIZATION_ID
    AND OL.BOOKED_FLAG = 'Y'
    AND OL.FLOW_STATUS_CODE ='AWAITING_SHIPPING');
    --NEED TO GROUP BY THE SUMATION OF QTY , IF SAME ITEM IS ADDED MORE THEN ONE LINE
    BEGIN
    ---DBMS_OUTPUT.ENABLE();
    CREATE GLOBAL TEMPORARY TABLE TMP_PICK_LIST
      --SLNO INT
      FGCODE VARCHAR2(25),
      INCODE VARCHAR2(25),
      LPN_ID INT,
      LPN_NUMBER VARCHAR2(30),
      QTY_AVAILABLE INT,
      QTYALLOCATE INT,
      ITEMTYPE VARCHAR2(10),  -- FG OR IN TYPE OF ITEM ALLOCATED
      PACK_OR_LOOSE VARCHAR2(10), -- PACKED ITEM OR LOOSE
      SUBINVENTORY VARCHAR2(20),
      LOCATOR_ID INT,
      LOCATOR VARCHAR2(20)
    ) ON COMMIT  PRESERVE ROWS;
    FOR REC in C1
    LOOP
      -- QUANTITY NEED TO ALLOCATE
      QNTY_REQ := REC.ORDERED_QUANTITY;
      QNTY_ALLOCATED  :=0;
      /* START : ALLOCATE FG QUANTITY IF AVAILABLE  */
      --CHECK FG ITEM AVAILABLE IN THE ORDERED SUBINVENTORY ?
       SELECT COUNT(1) INTO FGONHAND_CNT FROM MTL_ONHAND_QUANTITIES_DETAIL 
                  WHERE ORGANIZATION_ID = varORGANIZATION_ID AND INVENTORY_ITEM_ID = REC.FG_INVENTORY_ITEM_ID  AND SUBINVENTORY_CODE = REC.FG_SUBINVENTORY;
       IF FGONHAND_CNT > 0 THEN
          SELECT SUM(TRANSACTION_QUANTITY) INTO FGONHAND_QTY FROM MTL_ONHAND_QUANTITIES_DETAIL 
                     WHERE ORGANIZATION_ID = varORGANIZATION_ID  AND INVENTORY_ITEM_ID =REC.FG_INVENTORY_ITEM_ID  AND SUBINVENTORY_CODE = rec.FG_SUBINVENTORY;
          --IF THE AVAILABLE FG ONHAND IS LESS THEN EQUAL TO ORDER QUANTITY OR MORE
           IF ( FGONHAND_QTY <= QNTY_REQ ) THEN
                    INSERT INTO TMP_PICK_LIST (FGCODE          ,INCODE    ,LPN_ID, QTY_AVAILABLE      ,QTYALLOCATE         ,ITEMTYPE,PACK_OR_LOOSE,SUBINVENTORY     , LOCATOR_ID )
                                        SELECT REC.ORDERED_ITEM,REC.INITEM,LPN_ID,TRANSACTION_QUANTITY,TRANSACTION_QUANTITY,'FGITEM','LOOSE'      ,SUBINVENTORY_CODE,LOCATOR_ID
                                       FROM MTL_ONHAND_QUANTITIES_DETAIL  WHERE ORGANIZATION_ID = varORGANIZATION_ID
                                 AND INVENTORY_ITEM_ID =REC.FG_INVENTORY_ITEM_ID  AND SUBINVENTORY_CODE = rec.FG_SUBINVENTORY;
                --UPDATE ALLOCATED QTY
                QNTY_ALLOCATED := FGONHAND_QTY;
                --UPDATE QTY REQUIRED
                QNTY_REQ := QNTY_REQ - QNTY_ALLOCATED;
              END IF;
       END IF;
      /* END : ALLOCATE FG QUANTITY IF AVAILABLE  */    
      /* START : ALLOCATE IN TYPE ITEM IF AVAILABLE  */
          IF  QNTY_REQ > 0 THEN --IF YES , THEN ALLOCATE - IN TYPE OF ITEM
              SELECT COUNT(1) INTO varINONHAND_CNT FROM MTL_ONHAND_QUANTITIES_DETAIL 
                  WHERE ORGANIZATION_ID = varORGANIZATION_ID
                  AND INVENTORY_ITEM_ID = REC.IN_INVENTORY_ITEM_ID 
                  AND SUBINVENTORY_CODE IN ( varAFM_IN_TYPE_SUBINV );
              IF  varINONHAND_CNT > 0 THEN
                 CURSOR C2 IS
                 SELECT * FROM
                 (SELECT REC.ORDERED_ITEM,REC.INITEM,LPN_ID,TRANSACTION_QUANTITY QTY,SUBINVENTORY_CODE,LOCATOR_ID
                      FROM MTL_ONHAND_QUANTITIES_DETAIL  WHERE ORGANIZATION_ID = varORGANIZATION_ID
                       AND INVENTORY_ITEM_ID =REC.IN_INVENTORY_ITEM_ID AND SUBINVENTORY_CODE IN ( varAFM_IN_TYPE_SUBINV )
                       AND LPN_ID IS NOT NULL ORDER BY LPN_ID ASC);
                 FOR REC1 in C2
                 LOOP
                    IF REC1.QTY <= QNTY_REQ THEN
                       INSERT INTO TMP_PICK_LIST (FGCODE,INCODE,LPN_ID,QTY_AVAILABLE,QTYALLOCATE,ITEMTYPE,PACK_OR_LOOSE,SUBINVENTORY     , LOCATOR_ID )
                                     VALUES(REC1.ORDERED_ITEM,REC1.INITEM,REC1.LPN_ID,REC1.QTY,REC1.QTY,'INITEM','PACK',REC1.SUBINVENTORY_CODE,REC1.LOCATOR_ID );
                      --UPDATE ALLOCATED QTY
                      QNTY_ALLOCATED := QNTY_ALLOCATED + QTY;
                      --UPDATE QTY REQUIRED
                      QNTY_REQ := QNTY_REQ - QTY ;
                    ELSIF REC1.QTY > QNTY_REQ THEN --IF LPN HAVING MORE THEN REQUIRED
                      INSERT INTO TMP_PICK_LIST (FGCODE,INCODE,LPN_ID,                QTY_AVAILABLE,QTYALLOCATE,ITEMTYPE,PACK_OR_LOOSE,SUBINVENTORY     , LOCATOR_ID )
                                     VALUES(REC1.ORDERED_ITEM,REC1.INITEM,REC1.LPN_ID,REC1.QTY     ,QNTY_REQ,'INITEM','PACK',REC1.SUBINVENTORY_CODE,REC1.LOCATOR_ID );
                      --UPDATE ALLOCATED QTY
                      QNTY_ALLOCATED := QNTY_ALLOCATED + QTY;
                      --UPDATE QTY REQUIRED
                      QNTY_REQ := QNTY_REQ - QTY ;
                    END IF
                    IF QNTY_REQ = 0 THEN
                         EXIT;
                    END IF;
                 END LOOP;
                 CLOSE C2;
              END IF;             
          END IF;
      /* END : ALLOCATE IN TYPE ITEM IF AVAILABLE  */
    -- ELSE 
       --DBMS_OUTPUT.PUT_LINE(QNTY_REQ);
    END LOOP;
    --UPDATE LPN NUMBER & LOCATOR NAME
    --CLOSE C1;
    --DBMS_OUTPUT.PUT_LINE('M');
    END;    

    without going too much in depth about the code
    You error is here:
    BEGIN
    ---DBMS_OUTPUT.ENABLE();
    CREATE GLOBAL TEMPORARY TABLE TMP_PICK_LIST
    ...You're doing DDL inside a PL/SQL block. (creating the GLOBAL TEMPORARY TABLE)
    That is not correct.
    You would need to have that table created before running the PL/SQL block.
    Do not, never, create objects at runtime!

  • While Statement Help

    Hey, I'm having a problem with my while statement. I need to be able to have the program stop running when the input is Q. The only problem is that the input should otherwise be a number. I have to convert the user inputed number of dollars to euros using a previously inputed rate. So I can't just put everything as a String because then the equation doesn't work. Any help is welcome.

    gdawgrancid wrote:
    Hey, I'm having a problem with my while statement. I need to be able to have the program stop running when the input is Q. The only problem is that the input should otherwise be a number. I have to convert the user inputed number of dollars to euros using a previously inputed rate. So I can't just put everything as a String because then the equation doesn't work. Any help is welcome.A handy thing to do when solving ANY programming problem:
    1. Understand the problem, and what it is you have to do.
    2. Think of a solution in terms of english (or whatever your language may be)
    3. Put that solution into pseudo-code, which is often easier than working out what Java classes you might need.
    4. Take that pseudocode and code it in Java.
    Apply that to your current situation and the while loop should sort itself out.

  • Need Help:Reading Data from RU payroll cluster for table GRREC

    Hi...
    I need help on how to read data from RU cluster table for table GRREC for the employee & run date and get the value from structure PC292 .
    Please let me know about the includes and the import and export statements to be used.
    Thanks in advance,
    RAVI.

    Hi,
    Here goes pseudocode
    Includes:
    include: rpppxd00    ,
                rpppxd10     ,
                rpc2cd09     , 
                rpc2rx02_ce , "if ldb pnp_ce is used else use the same include with out _ce
                rpc2rx29      ,  
                rpc2rx39      ,
                rpppxm00    ,
                rpc2ruu0_ce ,
    Declare:
    DATA : i_rgdir   LIKE pc261        OCCURS 0 WITH HEADER LINE     ,
               i_result  TYPE pay99_result OCCURS 0 WITH HEADER LINE ,
               i_grrec   LIKE  pc292           OCCURS 0 WITH HEADER LINE .
    start-of-selection:
    GET pernr.
    Get the RGDIR VALUE for the current PERNR & selected Molga
    get rgdir data TABLES i_rgdir
                          USING pernr-pernr
                                     p_molga " parameter
    CD-KEY-PERNR = PERNR-PERNR.
    RP-IMP-C2-CU.
    i_rgdir [] = rgdir[].
      LOOP AT i_rgdir WHERE fpbeg  LE  pn-endda
                        AND fpend  GE  pn-begda
                        AND srtza  EQ 'A'
                        AND void   NE   'V'.
      get_result_tabs   TABLES i_result
                                   USING 'RU'    "  US cluster
                                         pernr-pernr
                                         i_rgdir-seqnr
          RX-KEY-PERNR = PERNR-PERNR.
          UNPACK i_RGDIR-SEQNR TO RX-KEY-SEQNO.
          RP-IMP-C2-RU.
      i_grrec[] = i_result-inter-grrec[].
      LOOP AT i_grrec.
      case i_grrec.
      use wage types required here and pass the data to output table.
      endcase.
      endloop.
      endloop
    end-of-selction.

  • Help if possible

    I am VERY VERY VERY new to Java Programming and I am trying to make a program in which I encrypt a 4-digit integer. I am supposed to have the user enter the four digit integer, and then change each digit to (the sum of the integer and 7) Mod 10. Then replace the first number with the third and the second with the fourth. I just can't figure out how to get each number to work on individually.
    If it helps in "Java: How to Program Third edition" it is problem 4.31. I don't want the whole code because this is for a class and I don't want to cheat, I just want a little push in the right direction. Thanks to anyone who can help me.

    Hi,
    "number /= 10" is the same as "number = number/10". I assume you know what the / operator does, but remember that if you use / on two ints, it returns an int,
    i.e. 19/10 = 1, and 19/10 != 1.9
    Because of this, "third = number%10" will assign a different value to third than the value in fourth: fourth contains number's last digit, third contains number's 2nd last digit.
    "reset number" is pseudocode, i.e. code intended to convey to humans what needs to be done, without actually writing all the messy code that the computer needs. The compiler would not understand it. I think what Svetlana meant was that the variable 'number' no longer holds your original number, but you may want your program to remember the unencrypted value, in which case you could reset 'number' to hold the original value when you've finished. But this isn't an essential part of the program, it depends on what you want.

Maybe you are looking for