Casting help.

I am creating code for a die tossing program. i have written the code the toss two die (36,000 times) and to add the the sums of the die and keep track of the number of throws for each possible sum. however, i am now trying to return the average number of throws for each sum. my problem is that the die face value and their sums are of the type int, and i need the average to be of the type double or float. i can't figure out how to cast correctly. this is what i have:
(float) average = faceCount/maxThrows;
where faceCount[i] is the total number of times each possible face sum was returned, and maxThrows was declared as 36,000.
any help is greatly appreciated. please let me know if you need any further info.

thank you. that worked! but, now there's an additional problem.
i have two loops set up. the first is the loop to complete the maxThrows, the second is to add up the sums and compute the average. the system needs to complete the maxThrows, then compute the average for each face sum. however, the way i have it written, the program rolls the die the maxThrows then computes the average for the sum of 2, then rolls the maxThrows again and computes the average for 3, . . . how can i change the order of the code so that it completes all maxThrows, then computes average for 2, average for 3, . . .
this is what i have:
for (int i = 1; i <=maxThrows; i++)
int face = greenDie.getFaceValueGreen() + redDie.getFaceValueRed();
faceCount[face] = faceCount[face] + 1;
faceCount[zero] = faceCount[zero] + 1;
for (int i= 2; i <= 12; i++)
average = ((double)faceCount)/100;
System.out.println("face = " + i + ": count = " + faceCount[i] + ": average = " + average);
System.out.println("Total count = " + faceCount[zero] + "\n");

Similar Messages

  • Apache Compilation Problem: makes pointer from integer without a cast -HELP

    Every time I try to compile apache with ssl I get this error message below. I'm pulling my hair out over it! I've installed current versions of gcc, libgcc, glib, make, m4, & flex.. which havent helped. I am running Solaris 9 sparc.
    I'm honestly baffled by this error and have found no help on the web. Does anyone know what I need to do in order to fix this? Any specific libraries I need to install etc??
    <apache compiles up to this point>
    gcc -c -I../../os/unix -I../../include -DSOLARIS2=290 -DMOD_SSL=208116 -DEAPI -DUSE_EXPAT -I../../lib/expat-lite `../../apaci` -fPIC -DSHARED_MODULE -DSSL_COMPAT -DSSL_ENGINE -I/tmp/web/sweeney/Third_Party/apache/openssl-0.9.7d/include -DMOD_SSL_VERSION=\"2.8.16\" ssl_expr_scan.c && mv ssl_expr_scan.o ssl_expr_scan.lo
    lex.ssl_expr_yy.c:1900: parse error before numeric constant
    lex.ssl_expr_yy.c: In function `ssl_expr_yy_scan_string':
    lex.ssl_expr_yy.c:1901: number of arguments doesn't match prototype
    lex.ssl_expr_yy.c:293: prototype declaration
    lex.ssl_expr_yy.c:1903: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
    lex.ssl_expr_yy.c:1903: warning: passing arg 1 of `ssl_expr_yy_scan_bytes' makes pointer from integer without a cast
    make[4]: *** [ssl_expr_scan.lo] Error 1
    make[3]: *** [all] Error 1
    make[2]: *** [subdirs] Error 1
    make[2]: Leaving directory `/tmp/apache_1.3.29/src'
    make[1]: *** [build-std] Error 2
    make[1]: Leaving directory `/tmp//apache_1.3.29'
    make: *** [build] Error 2
    they key being, "makes pointer from integer without a cast"
    Help me Obi Wan Kenobi, you're my only hope! Thank you much!

    I retried, here is the screen output:
    util.c: In function `ap_find_token':
    util.c:1367: error: `test_char_table' undeclared (first use in this function)
    util.c:1367: error: (Each undeclared identifier is reported only once
    util.c:1367: error: for each function it appears in.)
    util.c:1367: error: `T_HTTP_TOKEN_STOP' undeclared (first use in this function)
    util.c: In function `ap_escape_logitem':
    util.c:1444: error: `test_char_table' undeclared (first use in this function)
    util.c:1444: error: `T_ESCAPE_LOGITEM' undeclared (first use in this function)
    util.c: In function `ap_escape_errorlog_item':
    util.c:1496: error: `test_char_table' undeclared (first use in this function)
    util.c:1496: error: `T_ESCAPE_LOGITEM' undeclared (first use in this function)
    util.c: In function `ap_escape_shell_cmd':
    util.c:1567: error: `test_char_table' undeclared (first use in this function)
    util.c:1567: error: `T_ESCAPE_SHELL_CMD' undeclared (first use in this function)
    util.c: In function `ap_escape_path_segment':
    util.c:1671: error: `test_char_table' undeclared (first use in this function)
    util.c:1671: error: `T_ESCAPE_PATH_SEGMENT' undeclared (first use in this function)
    util.c: In function `ap_os_escape_path':
    util.c:1700: error: `test_char_table' undeclared (first use in this function)
    util.c:1700: error: `T_OS_ESCAPE_PATH' undeclared (first use in this function)
    *** Error code 1
    make: Fatal error: Command failed for target `util.o'
    Current working directory /source/apache_1.3.33/src/main
    *** Error code 1
    make: Fatal error: Command failed for target `subdirs'
    Current working directory /source/apache_1.3.33/src
    *** Error code 1
    make: Fatal error: Command failed for target `build-std'
    Current working directory /source/apache_1.3.33/
    *** Error code 1
    make: Fatal error: Command failed for target `build'
    Current working directory /appl/apa_ssl/apache_1.3.33/src
    *** Error code 1
    make: Fatal error: Command failed for target `build-std'
    Current working directory /appl/apa_ssl/apache_1.3.33
    *** Error code 1
    make: Fatal error: Command failed for target `build'
    root@host #
    the include-line in util.c is:
    #include "test_char.h" (vi: line 43)
    file exists:
    -rw-r--r-- 1 root other 0 Nov 8 16:02 test_char.h
    but, as you can see, it is empty

  • Video pod cast help

    i have succesfully added a video podcast to itunes thru iweb. the pod cast is up and running on itunes. i made the second podcast and put it into iweb. how do i get it to go to itunes? thanks for helpin the newb!

    Find the xml file belonging to the second podcast and note its URL. It's very likely at the root level of the folder the second site is in. Submit that to iTunes as a new podcast, just as you did with the first one.

  • Serious Vector Casting Help!!

    I have a Vector of Strings. I want to convert this to an array of strings. How do I go about this. Here is some code excerp
    public static String[] getHeader(Vector values, int format)
    Vector headerFields = new Vector();
    for( int i = 0; i < values.size(); i++ )
    headerFields.add(getString(i));
    return (String[]) headerFields.toArray();
    I get a class cast exception.
    Is there anyway to declare a String array and add strings to it whenever you like. Thanks

    OKAY, LAST TIME! in case it's not working
    please consider the code that was posted
    public static String[] getHeader(Vector values, int format)
    Vector headerFields = new Vector();
    for( int i = 0; i < values.size(); i++ )
    headerFields.add(getString(i));
    return (String[]) headerFields.toArray();
    1. In order to call the method "getString(i)" as shown, the method must exist in the same class or inherited from a super class, otherwise you would have to use a class name if it were static or a pointer if it were instance method
    2. In order for it to compile, it has to return an Object reference because that's the required parameter for the add method in the Vector class
    3. You are adding the value returned from this method into a newly created Vector refered to by "headerFields"
    4. The limit you are using for the loop is the size of the Vector refered to by "values"
    5. The only correlation between the Vector refered to by the pointer "headerFields" and the parameter "values" is the size. So you have two Vectors that are of the same length.
    6. In this code, the only way to get an Object out of the Vector values is to do it externally by allowing the "getString(int)" method to access a pointer that has the same value as the parameter "value". If you don't need an Object from the Vector refered to as "values" then you must simply want to use it's size. If so then just pass an "int" to the method.
    7.If you do want to get some information out of the Vector refered to by "values" then you should obtain the reference to one of it's elements as follows.
    values.elementAt(i)
    If you know what this Object is, then you may cast it appropriately and use the pointer to this particular Object to call a method in that Object. such as
    Something x = ((Something)(values.elementAt(i)));
    x.getString();
    8. If the class that contains this method extends Vector, and the class is intended to supply a getString(i) method, then why send the parameter "values" when you could use "this"
    9. If the class does not extend Vector but "has a" Vector, then you should hold a pointer or an array of pointers (for however many dimensions you need) in an instance field, then you wouldn't necessarily need to pass the "values" parameter.
    10. If the class has niether a "is a" or "has a" relationship to Vector, then certainly this is the wrong approach. You might want to do something with those objects in the Vector refered to by "values". then again you need to access them by
    values.elementAt(i)
    11. If you don't want to use the values in the Vector refered to by the "values" parameter and you want to use some method to get a header for each Object in the "values" Vector, then just send the size to the method.
    12. if you want to convert a Vector of strings then you don't need to create a new Vector in the method, just pass a Vector as a parameter to the method.

  • Cast in DMM integrated to IPTV----need some tips to improve the channel streams through 4400 DMP. Now the channel streams look little pixelated. Video not sharp...

    Hi,
    Some one kindly suggest a solution for the below issue.
    In one of my customer places we are using the Cast module in DMM 5.2.2 to integrate with the IPTV.
    So the IPTV channel streams when it comes to the LCD its not sharp.
    The feeds are a bit pixelated and also the scrolling news texts from the IPTV channels looks a little weird.
    When we browse the channels using the remote from the Menu the streams coming on the small window on the LCD screen is good but when we put the video to full-screen this pixelation happens.
    The streams are decoded using 4400 DMP and using HDMI connection.
    The receiver used is D9854 and the DCM used is D9900.
    I tried by changing the DMP display parameters but this was not resolved.
    We checked the DCM parameters and verified. The DCM parameters are correct and  when we stream the channels using VLC on our laptop the stream is good.
    So I kindly request to suggest some of the rectification techniques and as such we can resolve this

    JD - I appreciate the feedback - as an update, the customer is still adamant that the DMP is to be used only for digital signs and that now he expects Cast to run on all his PCs (I'm thinking Show and Share is the solution for this).  I try to only "know what I know" and not assume certain things - but this language seems pretty clear:
    "Features of Cisco Cast help your organization to deliver video-on-demand and live broadcast TV channels over IP networks to presentation systems that you connect to DMPs."
    http://www.cisco.com/en/US/docs/video/digital_media_systems/5_x/5_2/dmm/user/guide/cast/welcome.html
    To me that implies that cast delivery is done explicitly through DMPs but doesn't come out and *say specifically* such - but the way I remember doing it - you just publish your Cast setup to the DMP - there is no "cast server" that you can browse to per se and manipulate the guide, etc in that manner.  I'm always open to the idea that there's something I don't know - the IT business has humbled me many times - but this seems awfully straight forward to me.
    I'm stuck with the 2200's for cast - I have to try and make them work.  I assume the procedure is to link a stream to a multicast group address, then configure that as a channel target within Cast?  Never done it for real before - need to know by tomorrow ~noon.  Is there any reason why the 2200s would simply NOT work?
    Have you had success with remote control emulation?  I don't even know if the customer has UCM, but I have been informed that Cast is controllable by a mouse or keyboard (another assertion I'm 99.999% is incorrect) so I need to quit worrying about a remote.
    If I sound terrified, it's because I am.  Thanks for all the help.  I'm not confused yet because so far I've been right about everything I think I know, but when expectations don't line up with reality, that's when things get uncomfortable.

  • T cast(Object obj)

    Hi,
    What is the actual use of this method T cast(Object obj) that "casts an object to the class or interface represented by this Class object." ?
    If we pass the class token as a parameter then we already know what type it is and this seems to be the only way to to determine the concrete type at runtime. How is this method used ?
    Thanks,
    Mohan

    Class.cast helps you avoid an "Unchecked" warning. That's about all there is to it. Example:
    import java.util.HashMap;
    import java.util.Map;
    public abstract class Factory<T> {
         public abstract T newInstance();
         public static <TT> TT createObject(Class<TT> clazz) {
              Factory<?> factory = factories.get(clazz);
              if(factory == null)
                   throw new IllegalArgumentException("invalid class "+clazz.getName());
              return (TT)factory.newInstance(); // Unchecked warning
         public static <TT> void registerFactory(Class<TT> clazz, Factory<? extends TT> factory) {
              factories.put(clazz, factory);
         private static final Map<Class<?>, Factory<?>> factories = new HashMap<Class<?>, Factory<?>>();
    }The line with the comment will trigger an "Unchecked" warning, which could be avoided by using
    return clazz.cast(factory.newInstance());

  • Cast multiset help needed

    I have the following sql
    SELECT *
    FROM (SELECT updatedby, updateddate, ROWNUM,
    ent_id
    FROM (SELECT hstbe.updatedby,
    hstbe.updateddate,
    TO_CHAR
    (hstbe.entry_id
    ) ent_id
    FROM hst_rb_booking_entry hstbe
    --WHERE hstbe.entry_id = entryid
    UNION
    SELECT hstli.updatedby,
    hstli.updateddate,
    hstli.entry_id ent_id
    FROM hst_rb_line_item hstli)
    -- WHERE hstli.entry_id = be.booking_entry_id)
    ORDER BY updateddate)
    WHERE ROWNUM < 6)
    I am unable to put it in cat multiset as have to retrieve these as collection in my sql of ref cursor. please help me in putting it in cast multiset.

    Thenks for the reply.
    I have allready encounter this page in the past.
    I tryed to use "JIMI" wich is a good tool but I haven't found a function to control image resolution in it's documentation.
    If you do know how to control dpi threw "JIMI" please tell me.

  • Help needed in data type casting

    I have a java program which will receive data and its type in the String format. During program execution, the data in the String data has to be converted into the respective data type and assigned to a variable of that data type so that it could be used in the program. Programmer may not know the type of data that the value has to be converted into.
    I really got struck up with this. This is a RMI application and one process node is sending the data to another node in the String format and the type of data it should get converted into so that it can be converted into the respective type and used for computation.
    Can you understand what I am asking for ....if you can pls help and it is highly appreciated

    I dont know whether i ahve expressed it correctly
    look at this code
    dataPacket sendtoNode = send.senDatatoNode(inputReq);
    String recnodnum = sendtoNode.nodeNum;
    String recvarnum = sendtoNode.varNum;
    String recvartype = sendtoNode.dataType;
    String recvalvalue     = sendtoNode.dataVal;
    int num;     int type;
    double result;
    // here in this case the result variable type is double
    if (recvartype.equals("int")){
              type = 1;
         result = Integer.parseInt(recvalvalue); will pose problem
         else
         if (recvartype.equals("double")){
              type = 2;
              result = Double.parseDouble(recvalvalue);
         else
         if(recvartype.equals("float")){
              type =3;
              result = Float.parseFloat(recvalvalue); will pose problem
         else
         if(recvartype.equals("Boolean")){
              if ((recvalvalue.equals("true")) || (recvalvalue.equals("TRUE")))
              type = 4;
              result = Boolean.parseBoolean(recvalvalue); will pose problem
         else
         if(recvartype.equals("char")){
              type = 5;
              result = (char)recvalvalue; will pose problem
    else
    if(recvartype.equals("String")){
         type = 6;
              result = recvalvalue; will pose problem
         else
         if(recvartype.equals("byte")){
              type = 7;
              result = Byte.parseByte(recvalvalue); will pose problem
         else
         if(recvartype.equals("long")){
              type = 8;
              result = Long.parseLong(recvalvalue); will pose problem
         else
         if(recvartype.equals("short")){
              type = 9;
              result = Short.parseShort(recvalvalue); will pose problem
         //forvarval varvalue = new forvarval();
         //varvalue.forvarval(recvartype, recvalvalue);
    // this has to be done after sorting the problem of type casting string result = recvalvalue;
    //result = value; //<this will surely give me a problem as i m assigning string to double>??
    send.host(result);
    System.out.println("result received and the result is " +recvalvalue );
    now i need to assign the converted string in to a variable and use in the compuation ..thts where the challenge n not in teh conversion process...

  • Help on CAST function, defining TYPE TABLE and using a REF cursor

    Hi,
    I have written a procedure (lookup) inside a package (lookup_pkg) as shown below.
    Procedure has an output variable of type PL/SQL TABLE which is defined in the package.
    I want to write a wrapper procedure lookupref to the procedure lookup to return a ref cursor.
    CREATE OR REPLACE PACKAGE lookup_pkg AS
    TYPE t_lookup_refcur IS REF CURSOR;
    CURSOR c_lookup IS
         Select columns1,2,3,....100
                   FROM A, B, C, D, E
                   WHERE ROWNUM < 1;
    TYPE t_lookup IS TABLE OF c_lookup%ROWTYPE;
    Procedure lookup(id Number, o_lookup OUT t_lookup);
    End lookup_pkg;
    CREATE OR REPLACE PACKAGE BODY lookup_pkg As
    Procedure lookup(id Number, o_lookup OUT t_lookup) IS
    BEGIN
    END lookup;
    Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
    o_lookup t_lookup;
    BEGIN
    lookup(id, o_lookup t_lookup);
    OPEN t_lookup_refcur FOR
    SELECT *
         FROM TABLE(CAST(o_lookup AS t_lookup));
    Exception
    End lookupref;
    END lookup_pkg;
    When I compile this procedure, I am getting invalid datatype Oracle error and
    cursor points the datatype t_lookup in the CAST function.
    1. Can anyone tell me what is wrong in this. Can I convert a PL/SQL collection (pl/sql table in this case) to PL/SQL datatype table or does it need to be a SQL datatype only (which is created as a type in database).
    Also, to resolve this error, I have created a SQL type and table type instead of PL/SQL table in the package as shown below.
    create or replace type t_lookuprec as object
                   (Select columns1,2,3,....100
                   FROM A, B, C, D, E
                   WHERE ROWNUM < 1);
    create or replace type t_lookup_tab AS table of t_lookuprec;
    CREATE OR REPLACE PACKAGE BODY lookup_pkg As
    Procedure lookup(id Number, o_lookup OUT t_lookup) IS
    BEGIN
    END lookup;
    Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
    o_lookup t_lookup;
    BEGIN
    lookup(id, o_lookup t_lookup);
    OPEN t_lookup_refcur FOR
    SELECT *
         FROM TABLE(CAST(o_lookup AS t_lookup_tab));
    Exception
    End lookupref;
    END lookup_pkg;
    When I compile this package, I am getting "PL/SQL: ORA-22800: invalid user-defined type" Oracle error and
    points the datatype t_lookup_tab in the CAST function.
    2. Can anyone tell me what is wrong. Can I create a type with a select statement and create a table type using type created earlier?
    I have checked the all_types view and found that
    value for Incomplete column for these two types are YES.
    3. What does that mean?
    Any suggestions and help is appreciated.
    Thanks
    Srinivas

    create or replace type t_lookuprec as object
    (Select columns1,2,3,....100
    FROM A, B, C, D, E
    WHERE ROWNUM < 1);You are correct that you need to use CREATE TYPE to use the type in SQL.
    However unless I am mistaken you appear to have invented your own syntax for CREATE TYPE, suggest you refer to Oracle documentation.

  • Class cast exception in jsp plz help

    i have written a jsp where i displayed a text box with value given by user inside it
    when the user enters some other value in text box and clicks on update button then i forwarded reqeust to servlet which will some data base work
    servlet will forward again to the same jsp with the new value in text box.
    but i am getting CLASS CAST EXCEPTION when servlet is forwarding reqeust to same JSP
    help me what to do ........
    thanking you in advance ..cheers

    display cart.jsp file:
    <%@ page import="java.util.*,org.*" %>
    <html>
    <body>
    <%
    Vector cartupdate = (Vector)session.getAttribute("cartlist");
    for (int i = 0; i < cartupdate.size(); i++) {
    CartListBean clb = (CartListBean)cartupdate.elementAt(i);
    %>
    <form name="itemslist<%=i%>" action="updateCart" method="post">
    <input type="hidden" name="itemcode" value="<%=clb.getItemCode()%>">
         <input type="hidden" name="itemname" value="<%= clb.getItemName()%>">
    <input type="hidden" name="price" value="<%= clb.getPrice()%>">
    <%= clb.getItemName() %>
    <input type="text" name="qty" value="<%=clb.getQuantity()%>">
    <input type="submit" name="<%=clb.getItemCode()%>" value="update">
    </form>
    <br>
    <%
    %>
    <form name="tobuy" action="buysrv" method="post">
    <input type="submit" name="buy" value="BUY">
    </form>
    </body>
    </html>
    updatecart servlet code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import org.*;
    import java.sql.*;
    import java.util.*;
    public class UpdateCart extends HttpServlet
    public void service(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
    HttpSession session=request.getSession(false);
    Vector cartupdate = (Vector)session.getAttribute("cartlist");
    for (int i = 0; i < cartupdate.size(); i++) {
    org.CartListBean cart = (org.CartListBean)cartupdate.elementAt(i);
    if((cart.getItemCode()).equals(request.getParameter("itemcode")))
    org.CartListBean clb=new org.CartListBean();
    clb.setItemCode(request.getParameter("itemcode"));
         clb.setQuantity(request.getParameter("qty"));
         clb.setItemName(request.getParameter("itemname"));
    clb.setPrice(request.getParameter("price"));
    cartupdate.setElementAt(clb,i);
    session.setAttribute("cartlist",cart);
    ServletContext application=getServletContext();
    System.out.println("got finished");
              RequestDispatcher rd=application.getRequestDispatcher("/displaycart.jsp");
                   rd.forward(request,response);
    Message was edited by:
    143java

  • Java newbie help (type casting, 64bit unsigned Long)

    Hi I am java newbie and need help on my project. I have a few questions. Can you put strings in a hashtable and test for their being their with the appropriate hashtable method? I want to test for equal strings, not the same object. Second question can you use all 64 bits of an unsigned long? java doesn't seem to allow this. Any packages that do?
    Thanks,
    Dave

    Try casting it to Long instead of long. Long (capital L) is an Object, while long (lower case l) is not. You may also check to make sure the value isn't null. I would have thought that autoboxing would have worked here unless the value was null. But I am no expert on autoboxing.
    Edit >> Checking for null ain't a bad idea but has nothing to do with the problem - this is a compile time problem. Sorry.
    Also>> This code should work:
    long cTime=(Long)session.getAttribute("creationtime");Edited by: stevejluke on Jul 1, 2008 11:00 AM

  • HT3805 Sudden problem: Adjustment panel blank (metadata and library OK). Thumbnail shown as file loads but then  image has dark blue cast and is not adjustable.  Have current version of Aperture running.  Help please

    Aperture Help needed: Adjustment panel is blank, although metadata and library panels normal.  Thumbnails appear normal but when RAW (CR2) file is loaded, it appears with a dark blue cast, and does not load into the adjustment panel, and is not adjustable. Suggestions please

    You may need to register your camera with the the launch service database again, see this post by Alan Roseman: Re: Aperture 3 preview of raw file greenish
    There is a "typo" in the command given in the link above, so read also the following posts on how to correctly enter the command and how the fix is supposed to work
    Good luck.
    Post back, if this does not help.
    Regards
    Léonie

  • Help building an object, setting it in a session variable and casting

    Hi all,
    I have a problem that I hope you can help me with. The application I am working on has a simple MVC design architecture. The problem occurs when a request is made from the application to the controller servlet. The controller servlet looks at the request type and delegates the processing to the appropriate action and model classes. The model class returns an object of a specific class type that is put into the session variable. This session variable is then cast to the appropriate class type in the jsp that renders that class. The problem is that this particular class type has an array of another class type. The array is filled in the class constructor, but is null when returned to the controller.
    At run time when accessing the array I get a NullPointerException error. I can't seem to figure this one out. Any help is greatly appreciated.
    Here's the code:
    Controller DoPost method. The 'Action' objects are defined and initialized in the init() method.
            public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException{
                    try {
                            HttpSession session = request.getSession();
                            MemberProfileTbl memProf = (MemberProfileTbl)session.getAttribute("Member");
                            RequestDispatcher rd;
                            if (!validateUser(memProf, session)){
                                    session.setAttribute("LoginStatus", "Session Expired");
                                    rd = getServletContext().getRequestDispatcher("/LoginFail.jsp");
                                    rd.forward(request, response);
                                    return;
                            String act = getAction(request);
                            Action action = (Action)actions.get(act);
                            Object result = null;
                            try {
                                    result = action.perform(request, memProf);
                            }catch (NullPointerException npx) {
                                    npx.printStackTrace();
                            session.setAttribute("currObject", result);
                            rd = getServletContext().getRequestDispatcher("/test/MemberConsole.jsp");
                            rd.forward(request, response);
                    catch (Exception ex){
                            ex.printStackTrace();
    Action class:
            package accolo.actions;
            import javax.servlet.http.*;
            import accolo.model .*;
            import accolo.view.*;
            import accolo.db.MemberProfileTbl;
            public class ChangeMainView extends Action {
                    public String getName() {return "changeMainView";}
                    public Object perform(HttpServletRequest request, MemberProfileTbl memProf)
                            throws Exception, ClassNotFoundException, InstantiationException, IllegalAccessException{
                            Object result;
                            HMMainView hmMain = new HMMainView(memProf.email);
                           result = hmMain;
                           return result;
    HMMainView.java class
    public class HMMainView
            private HMMainViewJob[] jobs;
            public String test;
            public HMMainView(String email)
               HMJobsBean hmJobsBean = new HMJobsBean();
               JobTblDao jobTblDao = new JobTblDao();
               test = "test in constructor";
               try{
                 JobTbl[]  hmJobs = jobTblDao.getHMOpenJobs(email);
                 for(int j = 0; j < hmJobs.length; j++){
                            this.jobs[j].jobTitle = hmJobs[j].optionalTitle;
                            this.jobs[j].city = hmJobs[j].city;
                            this.jobs[j].state = hmJobsBean.getState(hmJobs[j].zipCode);
                            Hashtable counts = hmJobsBean.getJSCountsByStatus(hmJobs[j].jobId);
                            this.jobs[j].unranked = (String)counts.get("CANUNRANKED");
                            this.jobs[j].interviews = (String)counts.get("HMRI");
                            this.jobs[j].ranked = (String)counts.get("CANRANKED");
                            long closed = Long.parseLong((String)counts.get("HMRNI"));
                            closed += Long.parseLong((String)counts.get("HMCH"));
                            closed += Long.parseLong((String)counts.get("HMNH"));
                            this.jobs[j].closed = Long.toString(closed);
                }catch(Exception ex){
                    ex.printStackTrace();
            public HMMainViewJob[] getJobs(){ return jobs; }
    HMMainViewJob.java class
    package accolo.model;
    public class HMMainViewJob
            public long jobId;
            public String jobTitle;
            public String status_id;
            public String city;
            public String state;
            public String unranked;
            public String interviews;
            public String ranked;
            public String closed;
            public HMMainViewJob()
    Snippet of JSP that uses the code
      Object result = session.getAttribute("currObject");
      if (result != null){
        String className = result.getClass().getName();
        if (className.equals("accolo.model.HMMainView")){
               header = "HM/HMConsoleHeader.jsp";
               subNav = "HM/HMConsoleSubNav.jsp";
               user = "HM/HMConsoleUser.jsp";
               left = "HM/HMConsoleLeft.jsp";
    //           body = "HM/HMConsoleHome.jsp";
               HMMainView hmMain = (HMMainView) result;
               HMMainViewJob[] jobs = hmMain.getJobs();
              for (int i = 0; i < jobs.length; i++){
    %>
                    Jobs: <%=jobs.jobTitle%>
    <%

    I have not run this through a debugger yet. I don't have immediate access to a debugger to run it through, most of the development is simply done in vi. I was hoping any problem in the code would jump out at someone. I've been staring at it too long.
    I'll try to get a debugger set up.
    Thanks

  • Simple Casting in Java--Any help is appreciated

    I'm new to Java programming and I'm in an introductory class in school. I'm trying to create a method that casts a double value into an integer and not sure if I'm doing this right.
    public int calculateFunction(int x) {
         return y = x + (x * x) + (Math.pow(2,x));
    Math.pow returns a double value that I need cast into an integer or I keep getting loss precision errors. Not sure how to accomplish this. Any help would be appreciated.

    public int calculateFunction(int x) {
         c = Math.pow(2,x);
         return y = x + (x * x) + (c);
         y = (int) c;
    }Any half-decent compiler should issue some diagnostics here ...
    Casting from type double to type int is done as follows:double dValue= ...; // something complicated here
    int iValue= (int)dValue; // get rid of all the fraction digits etc.So, replacing the 'dValue' by 'x+x*x+Math.pow(2, x)', this results in:int iValue= (int)(x+x*x+Math.pow(2, x));and since you want to return that value, you can simply replace this by:return (int)(x+x*x+Math.pow(2, x));kind regards,
    Jos

  • Remove partial colour cast caused by out of focus bars? help please!!!

    I have several lovely images with a partial green horizontal colour cast caused by very out of focus bars, can anyone help me remove these? (without cloning!)
    as shown here, across tigers head!
    Thanks so much
    Emma

    why no cloning? they're an endangered species, do you want them to die out?
    On a more serious note, you can fix this with a Curves adjustment layer with a Layer Mask made with the Gradient Tool set to Reflected. Set two sample points in the tiger's head, one in a white part of his fur and one in a black stripe and then modify the channels in those two points while looking at the Info panel to make sure that you get those two points neutral. After that you will need to modify the RGB "channel" to get it to blend in with the rest of the image. It should look something like this:
    And here's my result:

Maybe you are looking for