Trouble with float variables

Hello!
I'm taking my first java class, and having some trouble. Our assignment is to "change your program so the variables you used to represent the x & y coordinates are declared as the float data type and change their default values to floats. Use the cast operator in your program so your program compiles and the washing maching displays on the screen."
But, when I changed the variables from "int xval=150" to floats, it won't compile. Anybody have any thoughts? Here's my code:
public class applet1 extends Applet {
public void paint ( Graphics g ) {
float xval=150.0f;
float yval=150.0f;
g.drawString ("Pete", 10, 10 );
g.drawString ("Assignment3 September 18, 2002", 10, 25 );
g.setColor(Color.white);
g.fillRect(xval - 150,yval - 150,350,350);
g.setColor(Color.black);
g.drawRect(xval-150,yval - 150,350,350);
g.drawLine(xval - 150,yval - 120,xval + 200,yval - 120);
g.fillOval(xval,yval - 145,20,20);
g.fillOval(xval - 105,yval - 145,20,20);
g.fillOval(xval + 100,yval - 145,20,20);
g.setColor(Color.lightGray);
g.fillOval(xval - 100,yval - 100,250,250);
g.setColor(Color.black);
g.drawOval(xval - 100,yval - 100,250,250);
g.setColor(Color.white);
g.fillOval(xval - 90,yval - 90,230,230);
g.setColor(Color.black);
g.drawOval(xval - 90,yval - 90,230,230);
g.setColor(Color.gray);
g.fillRect(xval + 170,yval - 110,15,25);
g.setColor(Color.black);
g.drawRect(xval + 170,yval - 110,15,25);
g.drawString ("Whirlpool", xval - 10, yval - 105 );

You can't use floats when the method requires ints; cast is needed.

Similar Messages

  • Smart Forms : problem with Float Variable

    Hi  Expert,
       I have a probelm with Float variable. In my smart forms one fields of table QAMV contain value like 8.0000000000000000E+01.
    I have to remove the exponent and display value like 80.
    I have tried wa_qamv-sollwert(E10.4).. but it not working.
    Can U suggest me some solution.
    Regards
    Swati.
    Edited by: Swati Namdev on Apr 27, 2010 12:19 PM

    Hi,
    Please follow the steps.
    1. In your smart form create a variable w_val ,, type,, associate type -->  CHAR10
    2. Now write a code, jsut above your node where u wud like to get this value... For this Create -> Flow Logic -> Program Lines.. Now you have editor..
    3. In input parameters , put i_tab-QAMV.. and in output parameter put w_val... and Code like below
    CALL FUNCTION 'MD_CONV_QUANTITY_FLOAT_TO_PACK'
      EXPORTING
        iv_menge       = i_tab-qamv
      IMPORTING
        EV_MENGE       = w_val.
    4. Now grag and drop this w_val from global data field list...your this w_val will have the rounded value.. Pls try this and check..   It will work.
    Regards,
    Lokesh.
    Edited by: Lokesh Tarey on Apr 27, 2010 9:28 AM

  • Trouble with session variables

    Hello, I am a user of cf for a number of years, but only
    lately as of last week have I had the opportunity to work with CF
    8.... wow the changes are quite intimidating. But none the less
    press on is my thought, so now my trouble. Thing I did was to start
    using application.cfc vs application.cfm, as it would appear that
    is how things have come to pass. So I looked around and found this
    code to set session management:
    <cfcomponent output="false" hint="Handles application
    level events.">
    <!--- Set up the application. --->
    <cfset THIS.Name = "AppCFC" />
    <cfset THIS.ApplicationTimeout = CreateTimeSpan( 0, 0, 60,
    0 ) />
    <cfset THIS.SessionManagement = true />
    <cfset THIS.SetClientCookies = false />
    <CFSET request.dsn = "wlaw" />
    </cfcomponent>
    My problem is that while I can define a session variable on a
    page that is not under the SSL cert, my session vars become
    undefined once I land on a page under SSL.
    Am I missing something? I dont recall this being a problem in
    the past. All help is appreciated.
    as to setting the var, it is done on an index page which
    calls another page in a different directory, but under the same
    server,.
    <cfset session.ref="foo">
    the only changes are that the result page or action page if
    you prefer is now under the ssl and the var becomes undefined.
    thank you in advance
    Mike Dooly

    is the object being put in session context serializable.. Also in
              other to avoid any generated classes issues delete all the classes
              whcih weblogic generates as part of deploying the application. That
              should atleast mitigate one explanation for your problem.
              Hope this helps
              ~a
              [email protected] (Gabriel Ornelas De Luna) wrote in message news:<[email protected]>...
              > Hello everyone,
              > I'm currently working with WL 6.1 and I'm having trouble with the
              > persistence of some session variables which are initially created
              > correctly on the server side, and they get lost (null) once the Web
              > clients need to access its value.
              > This is the error which is being written on a log file:
              >
              > <May 13, 2003 3:05:09 PM EDT> <Error> <HTTP Session> <Could not
              > deserialize session data
              > java.io.NotSerializableException:
              >
              > Things were woriking perfectly, but suddenly after bouncing the server
              > instance several times, in order to pick up the latest changes in my
              > classes, I started to get this error once the server tries to load the
              > jsp.
              >
              > JSP Code:
              > <%
              > Integer businessID = (Integer) session.getAttribute("business_id" );
              > Util.isCapitolBusiness(businessID.intValue())
              > %>
              >
              > I appreciate your help.
              > Regards.
              > g.
              

  • Having trouble with using variables in functions and after functions..

    Morning,
    I have simplified this, as it represents the core of what’s I obviously don't know how to do. 
    Problem:
    Say I populate that variable by reading in a list if IP addresses from file, finding the line that matches the hostname and place that string into the $IPAddress variable for use later throughout the script.   I did not run into a significant problem
    until I decided to convert the routine of looking up the IP address and populating the variable into a function.   As soon as I made it a function, and called that function, the $IPAddress variable only had the data in it until the function completed. 
    Once the function had done its work, and had placed the data into the variable, I expected that “new” data to be available after the function had completed..in that variable.  But it’s like the $IPAddress variable in the main script is a totally
    different data then the variable with the same name that’s used within the function. 
    So I think this demonstrates some of what’s kicking my butt.. 
    $IPAddress = "This is the wrong data”
    Function TestFunction () 
    $IPAddress  #call to display the contents of the variable at the start of the function. 
    $IPAddress = Read-Host -Prompt "Please enter the text ‘Goober’" 
    $IPAddress   #call to display the contents of the variable at the end of the function. 
    TestFunction
    $IPAddress ​
    The output I get is: 
    This is the wrong data
    "Please enter ‘Goober’"  : where I enter Goober
    Goober
    This is the wrong data
    Huh? 
    I had expected:
    This is the wrong data
    "Please enter ‘Goober’"  : where I enter Goober
    Goober
    Goober
    What good is the repeatability of a function if it’s output is lost? 

    THis seems to work.. IS there any reason NOT to do this?
    $Global:IPAddress= "This is the wrong data” #"
    Function TestFunction{
        Write-Host $IPAddress-fore green
          $host.ui.RawUI.FlushInputBuffer()
         $Global:IPAddress =
    Read-Host -Prompt
    "Please enter the text ‘Goober’"
        return$Global:IPAddress
    TestFunction
    return$Global:IPAddress

  • Trouble with evaluating variable

    I'm having a problem using a variable and evaluating it in a package and created a simple example to see what was happening.
    1. Created a project variable; type = numeric
    2. Created a package with a couple of steps:
    a. First step sets the variable to zero.
    b. Next step increments it by 1.
    c. Next step evaluates whether the variable is greater than zero.
    d. Final step sends me one email message if value > 0; if not it sends me a different message.
    When I execute the above package everything works as I would expect. The value of the variable at the end is 1 and I get the email I'm expecting.
    I then moved the step that increments the variable (2b) into its own package. I then replaced step 2b with a step to execute the scenario which updates the variable. Now when I run the package I can see that the value of the variable at the end is still 1; however, the process now takes the branch in 2d for when the variable is NOT greater than zero.
    Is this just how ODI works or am I missing something? Can you not set a variable in one scenario and then evaluate it from the called scenario? Is it a scope thing? In my example the interfaces/packages/scenarios/viarables are all in the same project.
    Thanks.

    Actually, each odi SESSION keeps its own variable values.
    So, when you execute a child-scenario, you must pass the value of the variable from master package to child scenario.
    To do that, you must :
    1) enter the name of the variable in the tab called "additionnal variables" of the step
    2) put the variable in the child package in DECLARE mode

  • Trouble with Resetting Variables

    Hello,
    I have created a series of 5 questions with two possible answers - correct and incorrect. I have created a variable for each, RunCorrect and RunIncorrect and have set them with a value of 0. Additionally I created a 3rd variable called EarnedShield. When the user clicks the correct option, RunCorrect is assigned 1 with an expression of RunCorrect = RunCorrect + 1 and EarnedShield is assigned 1. If they click the incorrect option, RunIncorrect is assigned 1. On the following screen, if RunCorrect is great than or equal to 1, a badge is displayed. If RunIncorrect is equal to 1, then a "sorry" message is displayed and if EarnedCorrect is equal to 1 then a "congratulations" message is displayed. When the user click the Next button, RunIncorrect and EarnedShield are Assigned 0 to "reset".  This allow me to display a badge for each correct answer and no badge for an incorrect answer.
    This works perfectly the first time through the series of questions. However, I need for the user to be able to Try Again after they have been through all 5 questions. Knowing I need to reset the variables, I created an Advanced Action to "reset" them to 0 with Assign RunCorrect with 0, Assign RunIncorrect with 0, and Assign Earned Shield with 0. This is triggered when the user clicks the Try Again button.
    However, the variable do not reset.
    Below is the actual advanced action I am using to "reset" the variable - executed on click of Try Again button. PS, I have also tried to execute this advance action (minus the Jump to Slide) on Enter of the first slide in the series of question. No luck.
    Any help would be appreciated.
    I am using version 6.0.1.240.
    Thank you,
    Susan

    When debugging issues with variable values sometimes the only way to see what is going on is to set up text captions that display a readout of the current variable values at any given slide.  You can add these captions to Master Slides if using them.  Or just add them to the starting slides and set to display for Rest Of Project.  Either way, you need to be able to see what the variables are set to at any moment.  Then you may find that what you thought was working isn't, and what you thought wasn't working is.

  • Trouble with private variables

    I have an XML parser running inside a GUI. my problem is that I have the actual parse command inside the actionPerformed method, so that when the user specifies their search conditions, those entities that match those conditions will be the only ones returned from the parse. My problem is that although I have the first thing happening when you hit the search button is to grab the contents of the search fields, the first thing that happens is the XML file is parsed, resulting in a NullPointerException when the parser tries to compare data with the search conditions, which is says are not set. I've already made the strings that will contain the data class-wide variables, but that didn't work. I have found that the variables are set inside the actionPerformed function, but once control leaves that function to the parser, they're no longer set, as if they have been wiped out of scope. any suggestions??

    okay, It is a map with a rubber-banding box for selecting latitiude-longitude coordinates. I have, inside the actionPerformed method, a utility that copies the values inside the textfields into String variables. these variables are declared as private members of the class that both of these methods belong to. I have it set up so that it is supposed to pull the value of the textfields into the strings BEFORE it parses the XML file. I even have the parsing of the XML file inside a finally clause and the setting of the variables in the try, so it's supposed to pull in those variables first no matter what, and it still refuses to get the values.

  • Trouble with date variables

    I have an Oracle Source database and a SQL Server Target database. I need to do the following:
    1. Get Max Date from target SQL Server table and assign to a variable
    2. Get Max Date from source Oracle table and assign to a variable
    3. Create a filter on Oracle source table that includes the statement "Prod_Date >= #Target_Max_Date - #Source_Max_Date"
    Variables are Global and are of type "date". My test using one or both variables returne the error: "ORA-00911: invalid character". I know if I write a sub-query to test this in TOAD it works (ie: where Prod_Date <= (select max(Prod_Date)...."
    Prod_Date is obviously type "Date".
    Suggestions anyone?

    Where in operator do I check the format of the date?
    Also, I have tried using the following formatting:
    Prod_Date >= Prod_Date - ('#FDC_WELL_PROD_EST_Max_Date' - '#Well_Prod_Daily_Max_Date') - 45
    Result: ORA-01722: invalid number
    A date is a number, so any ideas why the variable is being considered a number?
    and
    Prod_Date >= Prod_Date - (TO_DATE('#FDC_WELL_PROD_EST_Max_Date','DDMMYYYY') - TO_DATE('#Well_Prod_Daily_Max_Date','DDMMYYYY')) - 45
    Result: ORA=-01858: a non-numeric character was found where a numeric was expected.
    In this scenario, it would seem we are trying to convert a date to a date?
    Appreciate your responses.
    Edited by: Becker on Jul 24, 2009 7:13 AM

  • Trouble with Environmental Variables

    I am having a heck of a time setting the path varialble for J2skd1.4.0. I am using XP home edition and this is the path %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;c:\j2sdk1.4.0\bin. Is that correct? Thanks in advance for the assistance. I should say that I have rebooted after attempting to update the path, and the java text files are in the same root directory as j2sdk1.4.

    What happens when I try to run javac is that I get the message: 'javac' is not recognized as an internal or external command, operable program or batch file. I have not set the classpath yet, but in the past the program seemed to work without it.

  • A little bit of help with Bind variables please

    Hi,
    I am having a bit of trouble with bind variables I have been looking at the Dev guide and the forum to try and achieve this and it is still not happening for me, could anybody please help or point me in the right direction:
    I have created a simple PersonVO with the basic query:
    Select distinct full_name from xxml_people where person_id = :1
    In the PersonVOImpl.java I have added the method:
    public void initQuery(String personId)
    Number person = null;
    try
    person = new Number(personId);
    catch
    (Exception e){}
    setWhereClauseParam(1,person);
    executeQuery();
    Then in the PersonAM I have added the method:
    public void initPersonQuery(String personId)
    getPersonVO1().initQuery(personId);
    I then call this method in my processRequest section of my page controller:
    PersonAMImpl am = (PersonAMImpl) pageContext.getRootApplicationModule();
    String personId = "581";
    am.initPersonQuery(personId);
    When I try and run this I get the error:
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT distinct full_name from xxml_absence_calendar where person_id = :1
    java.sql.SQLException: ORA-01006: bind variable does not exist
    Am I binding the variables correctly? Or am I making some stupid mistake?
    I am ultimately looking to create a messageChoice where the logged in user will see a list of all organisations underneath him and the one level above. I plan to do this by passing the User’s Organisation name into a VO query using the organisation as a Bind Variable. I think once I have worked out how to bind variables this should be straight forward.
    Many Thanks

    Even though the parameter binding values may be same, you should never use the positional param more than once. So always go for the format
    select distinct full_name from xxml_people where supervisor_id = :1
    UNION
    select distinct full_name from xxml_people where person_id = :2
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Having trouble with variables followed by a period in user defined reports.

    Using SQL Developer 1.0.0.15 on XP.
    The DB is Oracle 10.
    Having trouble with variables followed by a period in user defined reports.
    select * from &OWNER.TABLE_NAME
    I noticed that the "Data Dictionary Reports" use :OWNER
    So I have tried all sort of variations:
    select * from :OWNER.TABLE_NAME
    select * from :OWNER\.TABLE_NAME
    select * from ":OWNER".TABLE_NAME
    select * from ':OWNER'.TABLE_NAME
    select * from (:OWNER).TABLE_NAME
    And every other variation I can think of. This is a simple example, but all my reports need the owner of tables as a variable.
    I assume this is simple, I just have not hit the right combination.
    Thanks -
    Dyer

    Use two points ..
    select * from &OWNER..TABLE_NAME

  • Trouble with first progråµ

    I'm having trouble with my simple calculator, which is similar to the calculator in "cocoa programming for dummies".
    http://public.me.com/schoolkid144
    its firstproject.zip
    The trouble is that when I get the value of the two text fields, it always returns 0 even when the value of both text fields is 1.

    Hi S-T Programmer, and welcome to the Dev Forums!
    The connections between the FuseBox outlets and the three text fields just need to be reversed in Interface Builder. An IBOutlet instance variable is associated with an Interface Builder object by Ctrl-Dragging from the object which owns the variable to the object the variable wants to reference. For example, to connect the FuseBox ivar named answerField to the text field which is to display the answer, Ctrl-Click on the FuseBox icon in the xib window then drag to the desired text field object. The text field object may either be found as an icon in the xib (Document) window, or as the full-scale drawing of the object in the IB Editor window (where you lay out the view). When you release the mouse at the end of the drag, a black list of all the FuseBox class outlets will pop up. Select the outlet you meant to connect (in this case answerField), and the connection will be made.
    The problem with giving IB instructions in the forum is that a picture is worth a thousand words, and this post is on the wrong side of that equation. So I'm hoping you'll be able to see enough of the picture from all these words. There are two other ways of making IB connections that are harder to use, but easier to explain:
    1) If you Ctrl-Click (without dragging) on any icon in the xib window, a floating, black panel will pop up showing every possible connection to that object. To make the same connection discussed above from the answerField outlet to the right-hand text field, Ctrl-Click on the FuseBox icon and find answerField in Outlet list. You can now drag directly from the connector symbol to the desired text field. This time there's no popup when you release the mouse because IB already knows which outlet is to be connected. After the connection is made, you can Ctrl-Click on the text field icon and see its connection panel. You'll know the connection is going in the right direction when the connection to the text field is listed under +Referencing Outlets+ and the connection back at the FuseBox object is listed under Outlets.
    The floating, black connection panels are especially useful for deleting connections. Since your project currently has three backwards connections, you can use these panels to delete those by clicking on the 'X' which is visible on each connection line.
    2) There's also a tab in the Inspector window for making connections. Select one of the objects you want to connect and select Tools>Connections Inspector from the top menu if you have trouble finding the tab. You can make connections in this window if you want, but you can also use the Connections Inspector to view the connections previously made by dragging.
    This topic is covered in more detail (including some screen shots! yay!!) under Creating and Managing Outlet and Action Connections in the +Interface Builder User Guide+.
    I think your connection between the Calculate button and the FuseBox was correct. This post has gotten so long I can't remember if I had to reverse that one too, but I don't think I did. Anyway you'll be able to check for yourself now that you know what to look for, right? The connection between an object's Sent Action and an IBAction method goes in the direction opposite to an IBOutlet connection. Thus to connect the Calculate button you need to drag from the button to the FuseBox.
    _Outlet from_ the FuseBox
    _Action to_ the FuseBox
    Hope that helps!
    \- Ray

  • A trouble with "LIKE" in a select statement

    Hi!
    I'm having trouble with "LIKE" in a select statement...
    With Access I can make the following and everything works well:
    SELECT name, birthday
    FROM client
    WHERE birthday LIKE '*/02/*';
    but if try to do it in my application (it uses Access), it doesn't work - I just can't understand that!!!
    In my application the "month" is always the currently month taken from the "System". Look what I'm doing...
    String query1 = "SELECT name, birthday " +
              "FROM client " +
              "WHERE birthday " +
              "LIKE '*/" +
              pMonth +
              "/*' " +
              "ORDER BY birthday ASC ";
    ResultSet rs = statement1.executeQuery(consulta1);
    boolean moreRecords = rs.next();
    The variable "moreRecords" is always "false", the query returns nothing although the table "client" has records that attend the query.
    Please, anyone can help me?! It's a little bit urgent.
    Thanks,
    Katia.

    Hi Katia,
    I'll bet the problem lies with the characters you're using to escape the LIKE clause. You're using the ones that Access likes to see, but that's not necessarily what's built into the JDBC-ODBC driver class.
    You can find out what the correct escape wildcard characters are from the java.sql.DatabaseMetaData.getSearchStringEscape() method. It'll tell you what to use in the LIKE clause.
    I'm not 100% sure about your code. It doesn't use query1 anywhere. I'd do this:
    String query = "SELECT name, birthday FROM client WHERE birthday LIKE ? ORDER BY birthday ASC";
    PreparedStatement statement = connection.createStatement(query);
    String escape = connection.getMetaData().getSearchStringEscape();
    String test = escape + '/' + pMonth + '/' + escape;
    statement.setString(1, test);
    ResultSet rs = statement.executeQuery();
    while (rs.hasNext())
    // load your data into a data structure to pass back.
    rs.close();
    statement.close();Let me know if that works. - MOD

  • Detail view with bind variable. TreeTable not showing all detail result.

    I’m having trouble with treeTable using detail view with bind variables and where clause defined in VO definition.
    Both, master and detail view objects, base on the same entity and have the same condition in where clause. The view objects also have bind variables, which are set in prepareRowSetForQuery() method.
    Again, these are two different views, that get different result, based on value of one of the bind variable.
    When I show results in two different tables on jsf page, where master table has "RowSelection" set on "single", all results are displayed in detail table.
    But when I use treeTable, only the first result of the detail is shown.

    I tested it in applicationModule and it works, but i think that's the same as two tables on a jsf page.
    This is the order in which overridden methods are called in ADF BC or two tables on jsf page
    when clicking on row in master table.
    PrepareRowSetForQueryDetail
    executeQueryForCollection_Detail user param: 2
       Object 2: class [Ljava.lang.Object;  -> print of the object2[] parameter in executeQueryForCollection
         List 0: Bind_ChildId -> viewLink parameter
         List 1: 400035313 -> viewLink parameter value
    getEstimatedRowCount_Detail
    count: 2
    getEstimatedRowCount_Detail
    count: 2 And when i click on "expand node" in tree table:
    getEstimatedRowCount_Root
    count: 2
    PrepareRowSetForQuery_Detail
    executeQueryForCollection_Detail user param: 2
       Object 2: class [Ljava.lang.Object;
         List 0: Bind_ChildId -> viewLink parameter
         List 1: 400035321
    PrepareRowSetForQueryDetail
    executeQueryForCollection_Detail user param: 2
       Object 2: class [Ljava.lang.Object;
         List 0: Bind_ChildId -> viewLink parameter
         List 1: 400035313
    getEstimatedRowCount_Root
    count: 2
    getEstimatedRowCount_Root
    count: 2
    getEstimatedRowCount_Root
    count: 2
    PrepareRowSetForQueryDetail
    executeQueryForCollection_Detail user param: 2
       Object 2: class [Ljava.lang.Object;
         List 0: Bind_ChildId -> viewLink parameter
         List 1: 400035313
    PrepareRowSetForQueryDetail
    executeQueryForCollection_Detail user param: 2
       Object 2: class [Ljava.lang.Object;
         List 0: Bind_ChildId -> viewLink parameter
         List 1: 400035321
    getEstimatedRowCount_Root
    count: 2
    getEstimatedRowCount_Root
    count: 2Values of user parameters are OK. Is there another method that i should override?
    I also noticed, that if detail view doesn't have user bind variables, the tree works fine and is shown even in ADF BC (aplication module).
    I guess we loose a tree, when using bind variables in detail view object.
    Is there a way around it?

  • Help with formula variable that will give me period #

    column A = $  for fiscal year period  variable  (using 0RMA_FIP,  SAP delivered variable for period)
    Column B = $ for fiscal year period  variable minus 1  (previous period)
    In Column C,  if fiscal year period entered in 0RMA_FIP was 001/YYYY  (january)  I want column C to be zero,  if not,  it will be a variance between column A & Column B.
    I think know how to do boolean logic:  (FV_Period == 1) *0 + (Column B % Column A)
    What i am having trouble with is creating FV_Period  as a replacement path formula varialbe so that it will contain the value of the period,   1 for January,  or 2 thru 12 for other months..

    While creating the Formula variable with replacement type, you need to mention the offset start and offset length.
    I believe if your Fiscal Period is displayed as 2010009 then
    offset start = 5 and offset length = 3 should give you the value 009 which is required.

Maybe you are looking for