Same runtime result no matter the input, but no compilation errors

I'm getting the same runtime result no matter what input I put into the program. This program is designed to check whether or not the two numbers inputted are approximately the same when rounded off by two decimal points. This is what I get during runtime, for any values entered:
Enter the first float-point number: 2.0
Enter the second float-point number: 1.7
The values are not equal.
I get the statement "The values are not equal" no matter what two numbers I put in. I'm not sure why this occurs.
Here is what my code looks like, this is the constructor:
     A class that takes two inputs and judges whether they are numerically close enough by two decimal places.
public class FloatPoint
          Constructs two numbers inputted by the user for tests.
          @param number1 first number inputted by the user.
          @param number2 second number inputted by the user.
     public FloatPoint(double number1, double number2)
          n1 = number1;
          n2 = number2;
          Runs the test to see whether the numbers are close enough or not.
          @return the result of the gap test.
     public String getComp()
          String o = "The values are teh equal.";
          if (Math.abs(n1 - n2) == EPSILON)
               o = "The values are equal";
          else if (Math.abs(n1 - n2) != EPSILON)
               o = "The values are not equal.";
          return o;
     final double EPSILON = 1E-2;
     private double n1;
     private double n2;
And here is the tester:
import java.util.Scanner;
     A class that tests the FloatPoint class.
public class FloatPointTester
     public static void main(String[] args)
          Scanner in = new Scanner(System.in);
          System.out.print("Enter the first float-point number: ");
          double i1 = in.nextDouble();
          System.out.print("Enter the second float-point number: ");
          double i2 = in.nextDouble();
          FloatPoint newFloat = new FloatPoint(i1, i2);
          System.out.print(newFloat.getComp());
}If anyone could point me in the right direction I would surely appreciate it. Thank you.

I was actually just copying from an example given in my textbook... I suppose it was the wrong example to copy from. I'm trying to see whether the difference is so small that it can be considered negligible, IE. be rounded by two decimal places and considered the same if the gap were that small. How could I write this properly?

Similar Messages

  • Greetings: I have multiple iPads and iPhones. I want all to be able to be able to stream to our Apple TV. All of the docs I see say you must have the same Apple ID for all the devices, but we each have our own Apple ID. Is this just a doc short coming?

    Greetings: I have multiple iPads and iPhones. I want all to be able to be able to stream to our Apple TV. All of the docs I see say you must have the same Apple ID for all the devices, but we each have our own Apple ID. Is this just a doc short coming?

    You can each have your own ID for your own iTunes accounts, but in order for a device to stream via AirPlay to the same Apple TV, everything must use the same homesharing ID. This is not the same as your iTunes account ID (although it can be for one of the devices)

  • I have a m-audio producer usb microphone and since the update on Dec. 22, 2013 Logic hasn't been allowing me to record with it. Logic is reading the microphone as the input but the audio tracks don't have the record enable button. What's wrong?

    I have a m-audio producer usb microphone and since the update on Dec. 22, 2013 Logic hasn't been allowing me to record with it. Logic is reading the microphone as the input but the audio tracks don't have the record enable button and won't let me select an input for the audio track on the inspector panel. What are some possible solutions.

    Certain M-Audio USB devices (along with some other USB2 class compliant devices that don't use drivers) no longer work with Logic Pro X 10.0.5
    At this time it is unknown as to why this has happened. Nor is it known if Apple will need to fix it or if it is up to the Developers of said USB2 devices  to remedy the problem.
    In the mean time, assuming you made/could make backups prior to updating to 10.0.5.... the solution is to roll back to LPX 10.0.4...

  • I'm having the same problems as some of the others, but s...

    I'm having the same problems as some of the others, but still don't see a corrective answer.  I'm having trouble viewing video through MSN without losing connection and having to reset the router.
    How do I roll back to my previous version of firmware?, and is that the only way to fix this problem, or has linksys offered any support?
    Thanks,
    Chris

    please let me know the model and version no. of the router, so that i can tell you what should be done...

  • HT1904 I purchased an iTunes card in the United States yesterday. I arrived home in the Bahamas today and tried to redeem the card  but got an error message stating that  I can only redeem  my card in a United States store. How to redeem a card outside th

    I purchased an iTunes card in the United States yesterday. I arrived home in the Bahamas today and tried to redeem the card but got an error message stating that  I can only redeem  the card in a United States store. How to redeem a card outside the US?

    Sorry - iTunes cards can only be redeemed in the country in which they were purchased.
    GB

  • I have ipod nano 6G.I was trying to restore it to clear all the data but it showed error 1439 and couldn't restore.I tried every method given in errors help page but nothing worked.What should i do?

    I have ipod nano 6G.I was trying to restore it to clear all the data but it showed error 1439 and couldn't restore.I tried every method given in errors help page but nothing worked.What should i do?

    Just in case (even though your symptoms aren't explicitly mentioned in the document), let's check to see if there's a LSP problem in play here:
    Apple software on Windows: May see performance issues and blank iTunes Store

  • I can see the input but have no output - and more!

    Howdy,
    I am dead in the water and am not sure what to do next.
    Here's my system and everything attached to it.
    OSX 10.4.11 / 2 x 2.66 Intel / 8 gb ram Mac Pro 1,1
    Apogee Ensemble - Firewire bus 1
    Maestro 1.7
    Daemon v1.4
    Driver v2.2Ofc9
    Firmware v1.9.24
    FPGA v1.31
    CPLD v1.6.1
    Powercore X8 - Firewire bus 2 (separate card)
    Software version 3.2.0.38
    Hardware version 3.2.0.36
    Firmware 3.0.0.3
    Novation Remote SL 25- USB
    Line 6 Tone Direct - USB
    POD Farm / Gear Box
    Everything was working fine until recently.
    Now, I cannot monitor inputs when recording real instruments. I can see the input on the level meters in Ensemble and in Logic's Channel strip but can't get any output in Stereo or headphones. After I record, it will playback what was input but without being able to hear what I'm playing, it's kind of pointless.... as a sidenote, I can hear / monitor the input normally if I record MIDI or software instrument.
    Also, I am getting the" Record drive/partition “Audio Files/Audio Recording” not found!" message which has already been reported as a bug although, for me, it's a new problem and seems to be related to the other problem.
    The only changes I have made in my system recently was to add a couple of new PowerCore plugs - the CL1B compressor and the Transient Modulator - which were both working fine until this. They still work fine on already recorded tracks.
    I have reinstalled Logic, reset hardware, unplugged / plugged everything back in / ran Combo install for 10.4.11 / upgraded to FWAudio 2.2.0, reinstalled Ensemble, updated software, etc.,
    I am stuck. Any suggestions???
    Thanks In Advance

    You're welcome. But I am afraid this is over my head - maybe you should contact Chris Lawson from Apogee - he posts here when there are questions concerning their stuff. and this seems hardware related to me. Maybe repost your question and use the word Apogee in your topic title, that'll get his attention...

  • What does the ejbc message 'Unexpected compiler error.  Result: 252' indicate?

    Every other Result I get provides a meaningful error message, but this is absolutely useless. How do I debug 'Result: 252'? This code comes from running EJBC via ANT. If I run it at the command line, I just get back 'Unexpected compiler error.' right away. I've double checked class names, file names, etc. What's dying here? 10 out of 12 of my beans compile, but those last 2...

    I had the same problem.
    It has to do with the classpath. I tried using other ejbc version and my problem was that I had a class not included in the classpath.
    Sal2, Sergio.

  • Class with interface, extends Sprite, but get compile error accessing "visible"

    Here is the situation:
    - Class MyLoader extends Sprite implements ILoader
    The class extends Sprite and works perfectly.
    var _loader:DisplayObject = new MyLoader();
    _loader.visible = true;
    Works perfectly.
    var _loader:ILoader = new MyLoader();
    _loader.visible = true;
    Casts a compiler error. Cannot access static property "visible" to a ILoader etc. etc.
    Doesn't make much sense to me, since the class extends a Sprite anyway...
    Am I missing something?
    thanks
    Filippo

    cast _loader as a Sprite (or DisplayObject);
    the flash compiler needs help remembering what's what.
    var _loader:ILoader=...
    Sprite(_loader).visible=true;

  • When any sound is played online it is terribly gitchy and sounds awful no matter the site, but saved music and games sound perfect.

    I just purchased a brand new desktop, athlon 2x dual core 260 with 4 gigs of ram. The computer just arrived yesterday in the mail and ever since first boot up no sounds play properly online (using IE and FireFox). The site doesnt matter, neither does the format. All drivers (realtek) and up to date and I just downloaded the most recent flash build. The problem persists if there is video or not. The real odd thing is that all saved music/video files sound perfect, so do games. Now if I stream music to WMP it sounds just fine, no problems, only when I try to play sounds from a site directly like youtube and the such. I have scoured all possible solutions online and have found no answers. Maybe someone could possibly solve this awful problem for me.

    and i run win 7 premium home - i just noticed that there is a volume control for a firefox plugin container in the sound mixer option - could there be an error with this?

  • After installation trying to start the portal but get credential error

    Hi
    I download the SAP Portal 7 and installed it as typical installation on Win XP. During the install it was asked from the wizard to put the master password. I did it and the installation was successfully finisched. Trying to start the server from the administration console i was asked to authenticate and put the username and password. After typing of the credential data i get in a message box: "invalied credential, start faild: 2"  and the start of the server fail. I retyped and even reinstall the Portal 2 times to be sure that i do not make a mistake by typing the master password but each time i get the same error!!!!!
    I installed it later again as custom installation and step by step put all neccessary passwords and the result was the same
    Please help to resolve this problem and get the portal a start
    Thank you for your help

    Hi
    Once you power on your unit keep tapping the F10 key go to Diagnostics menu Run the Hard drive & Memory test in case any test fails you need to replace the part. If both the test passes please let me know.
    Let us know how it goes!
    "I work for HP."
    ****Click the (purple thumbs up icon in the lower right corner of a post) to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    Regards
    Manjunath

  • SQL query works in the SQLPlus, but fires parse error after being cut and pasted into

    One of our client has a SQL query like this:
    SQL> SELECT LNAME,
    2 QUOTA/12,
    3 (SELECT SUM(CAMT) FROM CONSULTING WHERE CONSULTANT = P.EMPLOYEE
    4 AND ACTIVITYCODE = 'C'AND
    5 CDATE BETWEEN '01-JAN-2001' AND '31-JAN-2001') AS SUM,
    6 (SELECT SUM(CAMT) FROM CONSULTING WHERE CONSULTANT = P.EMPLOYEE
    7 AND ACTIVITYCODE = 'C'AND
    8 CDATE BETWEEN '01-JAN-2001' AND '31-JAN-2001') -
    QUOTA/12 AS PL
    9 FROM PERSONNEL P
    10 ORDER BY LNAME;
    Running the above query in the SQLPlus returns appropriate resultsets to the
    user. After the same SQL being cut and pasted into a portal report
    component, running the report component fires the following error:
    Failed to parse query
    Error:ORA-00911: invalid character (WWV-11230)
    Failed to parse as XXX - SELECT LNAME, QUOTA/12, (SELECT SUM(CAMT) FROM
    CONSULTING WHERE CONSULTANT = P.EMPLOYEE AND ACTIVITYCODE = 'C'AND CDATE
    BETWEEN '01-JAN-2001' AND '31-JAN-2001') AS SUM, (SELECT SUM(CAMT) FROM
    CONSULTING WHERE CONSULTANT = P.EMPLOYEE AND ACTIVITYCODE = 'C'AND CDATE
    BETWEEN '01-JAN-2001' AND '31-JAN-2001') - QUOTA/12 AS PL FROM PERSONNEL P
    ORDER BY LNAME; (WWV-08300)
    Cursor is not open
    Is this because of the multi-table queries, or something else? Is there any
    way around this? Any information regarding this will be highly appreciated.
    Thanks.
    null

    Sunny,
    From the error message that you posted it seems that you are putting a semicolon ";" at the end of your query. I checked the query that you have posted. It is working fine for me. (I am using 3.0.8) but I feel it will work in your version also. I tried the query without a ";" at the end --It worked.
    I tried with ";" at the end -- It gave the error that you have posted. So remove the ";" at the end and it should work. If you are still getting the same error then pls write down the version you are using. I will check in that version.
    Thanx,
    Chetan.

  • HT1539 Just bought a Blu-Ray disc, entered the code to transfer movie to iTunes (online, not from the disc), but get an error that iTunes timed out?  What is causing this?

    If anyone can assist, I would love to know.  Thanks folks.

    Have you seen this thread about Disk Utility's space message and different Blu Ray media?
    As to your other questions, I have very limited BluRay experience; the few times when I made a disk image it was for someone else's use or for testing workflows, but I know I didn't get into any weird encoding loops. As you know,the progress bar is pretty obscure by nature; alternatively, open up Batch Monitor and click on the info button do see what percentage has been complete.
    Assuming by now that you've canceled the job, I would download Digital Rebellion's Compressor Repair tool (free) and run that – including the trash preferences option. Also, I've had occasions when job actions started to act up and were cured by running repair permissions in Dick Utility.
    My impression is that the people who use disk images with Toast are happy with the results. So even if it's not something you get now, perhaps it's the long term solution.
    Good luck.
    Russ

  • PDF App works fine on Acrobat 7 but gives compilation Errors in Livecycle

    Hello,
    I have a PDF application that has been working fine in Acrobat 7 for years (for a Fortune 50 company). We had to upgrade our environments to Acrobat 8/9 and the same app either HANGS or Shuts Down when opened in Acrobat 8/9 (Reader and Professional). When I timed some sections of the code, I got down to the following statement (Click action of a button):
    xfa.host.resetData(Home.APHomeSF.somExpression)
    Where Home is a subform on page 1 and APHomeSF is a subform within Home form. This statement takes a fraction of a second in Pro 7 but 18 seconds in Pro 8. The APHomeSF subform has a checkbox, text field, date field and a button. Even when I changed the reset statement to resetting ONLY the checkbox:
    xfa.host.resetData(Home.APHomeSF.FCB.somExpression)
    Pro 8 still took 18 secs to reset the data.  My question is that have any BASIC things changed in Acrobat 8/9 from Ver 7 that are deprecated or not supported, which may cause our application to take longer to run or just shut down.
    I am using Livecycle Designer to edit the application. When I open the application in Livecyle and just save it, I get many "Argument mismatch in property or function argument" errors. Following is one of the places:
    Generating PDF Document...
    Font Service: Default font typeface is Myriad Pro.
    Script failed (language is javascript; context is xfa[0].form[0].CopyContent[0].#subform[0].SPOA[0].SPOAdataRow[0])
    script=viahScripts.noViahNulls();
    var groupsArray = Builder.variables.soScript.getGroupsArray();
    var name = CopyElementName.rawValue;  // PROBLEM LINE
    Error: Argument mismatch in property or function argument
    Now, when I delete the line "var name = CopyElementName.rawValue" with the comment PROBLEM LINE, the error goes away. CopyElementName is just a drop-down list.
    I don't understand what is wrong in this line for it to cause the Argument mismatch error.
    Any help will be appreciated.... THANKS!
    Sunny

    You may try the forum LiveCycle Designer.

  • "Warning: compiled but with compilation errors" while executing procedure.

    Hi All, i am so new to plsql. this code has been compiled but it gave a warning. I guess i am missing a small issue like semicolon but since im new i could not see what the problem is.
    CREATE OR REPLACE procedure BAKIM.grantt_uguser as
    cursor synn is
        select 'CREATE PUBLIC SYNONYM '||object_name||' for '||owner||'.'||object_name TXT from dba_objects
        where owner= 'FCY' and object_type in ('INDEX','PROCEDURE','TABLE','FUNCTION','VIEW','TRIGGER','SEQUENCE','PACKAGE')
        and
        object_name not in (select table_name from dba_synonyms where owner = 'FCY');
    begin
      for li in synn
      loop
    execute immediate li.TXT;
      end loop;
    end;

    Immediately after compiling, when you get the warning:
    select * from user_errors;
    In this case the root cause is "ORA-00942: table or view does not exist" because you probably don't have select on DBA_OBJECTS or DBA_SYNONYMS granted directly to BAKIM (it is probably through a role which is not sufficient for PL/SQL procedures).

Maybe you are looking for