Binary code-swiss cheese

I have made a program that converts a number to binary and if the number has more zeros than ones then I display "Too light." If it has more ones than zeros it displays too heavy. If they are equal it says "just right."
The program works on some numbers and not on others. I don't know what's wrong with the code. Any help is appreciated. Thanks in advance
import java.lang.*;
import java.lang.String.*;
import java.io.*;
public class Goldilocks
{//begins class
     public static void main(String[] args)throws IOException
     {//begin main
          String userInA;
          int binnum;
          String bin;
          int i = 0;
          int o = 0;
          InputStreamReader inStream =
                       new InputStreamReader( System.in ) ;
          BufferedReader stdin =
               new BufferedReader( inStream );
               do{//begin loop
          System.out.print("Please enter a number(A to quit): ");
          userInA = stdin.readLine();
          if(userInA.equals("A")){
               System.out.print("Thank you");
               System.exit(0);
          binnum = Integer.parseInt(userInA);
          bin = Integer.toBinaryString(binnum);
          System.out.println(bin);
          for(int n = 0; n<=bin.length()-1; n++){
               if(bin.charAt(n) == '1'){
                    i++;}
               else if(bin.charAt(n) == '0'){
                    o++;}
          if(i > o){
               System.out.println("Too heavy.");
          else if(o>i){
               System.out.println("Too light.");
          else{
                               System.out.println("Just right.");
               }while(userInA != "A");//end loop
     }//end main
}//ends class

You're welcome :-)
You should also add some verification for bad user inputs:
try {
    binnum = Integer.parseInt(userInA);
} catch (NumberFormatException e) {
    System.out.println("Bad number format");
    continue;

Similar Messages

  • How to display the binary code received from a DAQ Card

    Hi everybody,
    My LabVIEW application receives data from a NI-6036E DAQ Card. Is there a possibility to see the binary code sent by the card? Because all what I found show only the analog value.
    Thanks for your help

    Assuming that you are using DAQmx, simply select the polymorphic selector of the DAQmx Read and do a Analog>Unscaled and then pick the type of integer array you want. If you are using the DAQ Assistant, I don't think you can select unscaled for that so you could convert the assistant to a VI and modify that (right click on it and select Open Front Panel). If you are not using DAQmx, please provide the name of the function you are using.
    Message Edited by Dennis Knutson on 01-08-2007 08:31 AM
    Attachments:
    Select binary format.PNG ‏4 KB

  • Smartform in binary code

    Hi, i have a problem; when i execute a smartform, the spool of smartform is in binary code.
    How can i change the format of spool?
    Thanks.

    Hi trini,
    Hope this link will help u to convert smart form output to pdf.
    http://****************/Tutorials/Smartforms/OTF2PDF.htm
    Regards,
    Nithya.

  • Import Export Imges in JAVA to binary code with firebirds

    I'm having problems with a java netbeans. I want a start a disccus about how we can import and export images from and to, binary code. We can play with Blob variables, but i dont know how can we insert to a Firebird database and how we can read this image.
    Any help or any comment is great.
    Thank you!!

    Hi,
    I'm not sure how much help you'll find here as firebird is not an oracle product. You might find someone who can provide sample code for doing the above into oracle/mysql here. I would suggest asking in the database general forum though rather than this one - you should be able to get a moderator to move it if you can;t do it yourself.
    Cheers,
    Rich

  • Storage of Source and Binary Code of PL-Procedures in Database

    Hi all,
    I would like to know, whether the binary-code of PL-Procedures is stored in a db-table or is it stored only in some datafile.
    I know, that the source can be accessed from view all_source.
    But what happens during compilation of the code?
    If anyone has any information concerning this theme, I would be very thankful for receiving these.
    Thanks in advance.
    Oliver
    null

    I had read through some discussions on how the new
    USA Daylight Savings Time would affect Java but got a
    bit confused. My questions are:
    How are dates stored in the Database. If they are
    stored as a long value, as Java represents dates,This is usually not the case though. Dates are stored in a DB specific way. I would expect the same value out as in in this case.
    Or will a database store it's dates in context with the timezone it was specified? No. The database stores the date without timezone or local information.
    > What if you dumped a date to a binary file? The value
    stored in the file will be a long, right? So if I
    store March 31, 2007 using 1.4.2_6, then read it
    using 1.4.2_11, what will I see? That long value I
    stored no longer represents the same date, right?
    In this case the answer is yes. However it depends how you write the date. You could write it as a time stamp like YYYYMMDDHHMMSS and you end up with the same as you started with.
    If I were you and this is a concern I would do testing.

  • Possible to move Oracle binary code from one version of RHEL to another?

    Hello folks
    We are stuck with a 32 bit server running Oracle 10.1.5 database as well as Oracle Application Server 10.1.x under RHEL Linux 3 AS. Due to a SAN upgrade we need to upgrade the Qlogic HBA- and mulitipath drivers but find it extremely hard to find these drivers for such an old OS, so we are forced to move to a never version of RHEL (5 ES, most likely) and maybe new hardware too.
    The database and the OAS act as backends for a portal running on another server. The OAS runs OID (identity manager).
    We are not worried about porting the database. But we know that the OID in the backend is somehow registered with the frontend OAS through some kind of binary ID that might have to be changed in a hundred places in the frontend. Not something you like to fool around with a dark night in a service window.
    So we are looking at simply preparing a new server and move the binary code as well as data files, control files etc. from the old server into the exact same OS locations on the new server. That way, the binary IDs would be preserved.
    Here my Linux skills reach their limits. I guess, Willl binary code run on another version of Linux? I guess, if the code is statically linked, it should not depend on any OS-dependent libraries, or should it? I Is Oracle statically or dynamically linked? r What if the new server has a 64 bit OS?
    Any advice or comments?
    Yours
    Claus Jacobsen/Denmark

    You are right, Nicolas, it is a pity. But it is an old legacy system which will go out of production in about one year so we just need a temporary solution
    I will try your solution and maybe look around for an outdated 32-bit server if no one else has anything to add? Thanks for your advice.
    Yours
    Claus
    Edited by: user586249 on Feb 3, 2010 4:31 PM

  • How to create binary code ("10101") matrix with particles?

    Hi...I am trying to create a group of binary numbers that float across my composition in a loose group - the binary code should appear in lines of text, about 3 to 7 numbers wide (ideally constantly changing the number of digits as it animates).
    I was able to build ONE set of one alternating 1 and 0 with "numbers", but wasn't able to make the line of text wider then one digit. Also, the random number change animates very fast, and I don't know how to slow it down (is there an expression?).
    I then animated it with particular, but it looks more like a swarm of bees then moving and morphing  "lines" of 1's and 0's
    Any advice would be greatly appreciated....thank in advance!!

    http://www.redgiantsoftware.com/products/all/text-anarchy/
    http://www.motionscript.com/design-guide/binary-block.html
    http://aestuff.myleniumstuff.de/?p=82
    Mylenium

  • Web Reference inside Script Task causes Binary code for script not found error

    I am attempting to access a SOAP web API (sales force) from a SSIS package. To do this I created a script task.
    Inside the script task I went to Add Service Reference. Then I click advanced to make it a web reference. Then I point it to the WSDL file and give it a name SFEnterprise. It successfully finds and adds the Web Reference to the script task.
    I leave scriptMain.cs alone and I have no warnrings and no errors. Now in the solution explorer I right-click the script task and hit BUILD. I see the message from Output that BUILD succeeded.
    I close the VSTA script editor and now I am back on the control flow window. However I have a red X on the script task with the following message. "The Binary code for the script is not found. Please open the script in the designer by clicking EditScript
    button and make sure it builds successfully"
    But it does build successfully! And I have not even added any custom code except for the web reference using the WSDL file.
    I am using SSIS 2012 and Visual Studio 2012. I have been reading about this binary code error message on Google searches and suggestions about delay validation and turning off pre-compile do not apply to SSIS 2012.
    Is SSIS not capable of doing this?

    I was wanting to use the 2.0 coding style of accessing the soap service which is supported by adding the web reference vs. adding a service reference. But using a service reference instead of web reference actually allows the script task to compile. This
    is really odd behavior. I wonder why one works and not the other.
    Changing my C# code over to service reference coding style to access the SOAP service was still returning an error. When I added a break point I found the error message "Could not find default endpoint element that references contract in the ServiceModel
    client configuration section"when calling new SoapClient();
    I found this page http://www.sqlis.com/sqlis/post/Where-is-my-appconfig-for-SSIS.aspx and after I copied the System.ServiceModel app settings from the script task app.config to the DTSDebugHost.exe.config it was able to successfully login to the endpoint
    during package debug mode.
    This means I will have to edit the SQL Server DTS config files on the prod SSIS server to get the package to actually run in the job agent.
    So for now I am good I think just plugging away at coding what the script task is actually supposed to do now that is can actually login.

  • How to read binary code chars in pl/sql

    How can I read binary code characters in my script. I need to ignore any binary chars before sending the output to a text file.
    Thanks

    If they are in fact characters in the 1-20 range, you can do somehting like this:
    Create & populate the table:
    create table badChar (
      buf VARCHAR2(1000)
    insert into badChar values ( CHR(0) || CHR(1) )
    insert into badChar values( CHR(2) || CHR(3) || CHR(4) || CHR(5) || CHR(6) || CHR(7) || CHR(8) );
    insert into badChar values( CHR(9) || CHR(10) || CHR(11) || CHR(12) || CHR(13) || CHR(14) || CHR(15) );
    insert into badChar values( CHR(16) || CHR(17) || CHR(18) || CHR(19) || CHR(20) || CHR(21) || CHR(22) );
    insert into badChar values( 'Normal data' );View the data
    SQL> select '*' || buf || '*' from badChar;
    '*'||BUF||'*'
    Normal dataTranslate the data, removing characters with ASCII values of 0-22
    SQL> ed
    Wrote file afiedt.buf
      1  select '*' ||
      2         translate( buf,
      3                    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ||
      4                        CHR(0)  || CHR(1)  || CHR(2)  || CHR(3)  || CHR(4)  || CHR(5)  ||
      5                        CHR(6)  || CHR(7)  || CHR(8)  || CHR(9)  || CHR(10) || CHR(11) ||
      6                        CHR(11) || CHR(12) || CHR(13) || CHR(14) || CHR(15) || CHR(16) ||
      7                        CHR(16) || CHR(17) || CHR(18) || CHR(19) || CHR(20) || CHR(21) ||
      8                        CHR(22),
      9                    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ) ||
    10         '*'
    11*   from badChar
    SQL> /
    '*'||TRANSLATE(BUF,'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'||CHR(0
    Normal dataNote that I assume that the the "valid" values are a-z and A-Z. You can add numbers or other valid characters as needed.
    If you were on Oracle 10g, you could use regular expressions to make this a lot simpler.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Script Component WebService Binary code for the script is not found

    I am using SSIS 2012 to access a Public Web Service
     http://marketinformation.natgrid.co.uk/MIPIws-public/public/publicwebservice.asmx
    However, when adding reference to WebService (not Service Reference),
    I receive the dreaded msg "Binary code for the script is not found"
    I have spent an age ploughing through the forums.
    Many replies seem to suggest not using Script Component to acces WebService.
    Should I write a .NET app  ?
    Any thoughts how I should proceed would be most welcome.
    thanks JohnJames

    Hi JohnJames,
    If I understand correctly, you already add this public web service via Add Service Reference option in the Script Component. Then you receive the error message when you trying to call the bindings and Contract settings stored in app.config file to access
    the web service.
    Please note that we cannot all the web service normal way as SSIS Script Component task doesn’t recongnise the app.config file. To fix this issue, we should define the BINDINGS via code rather than depending on the App.config file. For more details, please
    see the following blog:
    http://social.technet.microsoft.com/wiki/contents/articles/22587.consume-webservice-via-ssis-script-component.aspx
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Using definition in orcale binary code license agreement

    using definition in oracle binary code license agreement for java se platform products:
    G. COMMERCIAL FEATURES NOTICE. For purpose of complying with Supplemental Term Section C.(v)(b) and D.(v)(b), your license agreement shall include the following notice, where the notice is displayed in a manner that anyone using the Software will see the notice:
    Use of the Commercial Features for any commercial or production purpose requires a separate license from Oracle. “Commercial Features” means those features identified Table 1-1 (Commercial Features In Java SE Product Editions) of the Software documentation accessible at http://www.oracle.com/technetwork/java/javase/documentation/index.html
    anyone using the Software : What kind of using is meant? (For example installing?)

    hello,
    thanks for your comment. please can you help me to find the correct forum.
    perhaps as oracle employee you can put it there?

  • The binary code for the script is not found error for the Script component - SSIS 2012

    Hi,
    I'm implementing a SSIS 2012 pkg. For a data flow task, I'm using a Visual Basic 2010 script component with an Oracle input flow. For the script component I've an input column and I've created an output column. Inside the script code I've edited only inside
    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer).
    The written code is:
    If Year(Row.OFFDATAORI) < 1900 Then
    Row.OFFDATAORIconv = CDate(CStr("1900" + "-" + Right("00" + CStr(Month(Row.OFFDATAORI)), 2) + "-" + Right("00" + CStr(DatePart(DateInterval.Day, Row.OFFDATAORI)), 2))
    Else : Row.OFFDATAORIconv = Row.OFFDATAORI
    End If
    It is to note that OFFDATAORI isn't the name of the input column for the script component.
    When I close the script component I've an error about "The binary code for the script is not found".
    Any helps to me, please?
    Thanks

    Hi,
    I've solved. There was a syntax error, a bit hidden.
    Bye

  • SPArrayAccess example display string as binary code,Why!!

    Hi!
    Anyone knows?
    I just run this oracle example SPArrayAccess to display a db VARRAY using java
    callerable statement, everything works except the the program tries to print the varray
    values (string) , but display the binary code for the string not the string itself.
    What went wrong for this oracle example?
    David

    1 error has occurred
    Invalid query, no select statement foundWhat if you try
    DECLARE
       p_vc_arr2   htmldb_application_global.vc_arr2;
       p_string    VARCHAR2 (2000);
    BEGIN
       SELECT ename
       BULK COLLECT INTO p_vc_arr2
         FROM emp
        WHERE deptno = :p84_select_deptno;
        return 'select ''' ||  HTMLDB_UTIL.table_to_string (p_vc_arr2, ':') || ''' str from dual';
    END;??

  • DAQ Return Data Binary Codes Format

    Hi!
    I'm working with ComponentWorks together with C++ Builder and i want to
    know the binary codes format when an acquisition is performed. My DAQ card
    is a PCI-MIO-16E-4.
    When i get the scaled data there's no problem.
    Thanks.

    Hello Marcel,
    Thank you for contacting National Instruments.
    NI does not have a tool that will convert into MDF format. There is a Plug-In for Diadem which allows you to read MDF files at http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=E267F645DF776A21E034080020E74861&p_node=201258 .
    The following website might be helpful to you. It has general information on MDF format and tools for creating MDF files. http://www.techquila.com/index.html
    I hope this helps,
    Sean C.
    Applications Engineer
    National Instruments

  • Can Shape model a cross section of swiss cheese or a doughnut?

    Can a GeneralPath or Area model a shape that has holes in the middle?
    Could a GeneralPath model a 2-d cross-section of swiss cheese or a doughnut?
    Do all the points of a GeneralPath need to be contiguous?
    According Ernimril in [this post|http://forums.sun.com/thread.jspa?forumID=5&threadID=612402] , a GeneralPath can have a hole in the middle, as long as the winding rule is set to WIND_EVEN_ODD. This seems to be confirmed by [the explanation of WIND_EVEN_ODD on the documentation for GNU Classpath|http://developer.classpath.org/doc/java/awt/geom/GeneralPath.html] , and [this nice forum post explaining the difference between the two winding rules|http://forums.sun.com/thread.jspa?forumID=54&threadID=781529] . However none of the examples given point to a shape that consecutive but noncontiguous points.

    Thanks for the tips! I've come up with an example that visually demonstrates that this can be done with GeneralPath or Area:
    // ShapeTest1.java
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    class ShapeTest1 extends JComponent
        Area _shape;
        GeneralPath _generalPath;
        ShapeTest1( Dimension d )
            setPreferredSize( d );
            // using Area
            _shape = new Area(
                new Ellipse2D.Double(
                    50, 50, 50, 50
            _shape.subtract(
                new Area(     
                    new Rectangle2D.Double( 60, 60, 20, 20 )
            // using GeneralPath
            _generalPath = new GeneralPath( GeneralPath.WIND_EVEN_ODD );
            _generalPath.append(
                    new Ellipse2D.Double( 150, 150, 100, 100 ), false
            _generalPath.append(
                    new Ellipse2D.Double( 160, 160, 50, 50 ), false
        @Override
        protected void paintComponent( Graphics g )
            super.paintComponent( g );
            Graphics2D g2d = ( Graphics2D )g;
            g2d.setColor( Color.BLACK );
            g2d.draw( _shape );
            g2d.setColor( Color.RED );
            g2d.draw( _generalPath );
        public static void main( String[] args )
            JFrame frame = new JFrame( "ShapeTest.java" );
            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            ShapeTest1 shapeTest = new ShapeTest1( new Dimension( 300, 300 ) );
            frame.getContentPane().add( shapeTest );
            frame.setLocation( 100, 100 );
            frame.pack();
            frame.setVisible( true );
    }

Maybe you are looking for

  • Can no longer access remote site in DW CS5

    I've recently upgraded to CS5, when I attempted to upload a PS file to my website in DW I foolishly denied the permissions for CS5.  This has changed my remote server somehow so I can no longer update the website.  Also I've lost all my folders on th

  • TS3992 My iphone 5 is no longer backing up photos from photostream

    My iphone 5 is no longer backing up photos from photostream although automatic backup is turned on and also photostream in both iphone and computer (Windows 8) and it used to work normally

  • File adapter: how to change filename

    Hi all, In my scenario I need to add specific time stamp (current date actually) to filename when it's copied to target system. In the properties of file adapter there is an option to add time stamp, but I need it to be in format YYMMDD.hhmm, while X

  • Roads don't appear in maps for Israel

    Hi, I just moved from the US to Israel and I noticed that the street names don't appear on the maps program in my iphone. The streets are perfect on google maps but don't appear on the iphone maps program. I can't use the directions feature. Why?

  • PerformancePoint Services - Rollup of Null KPI's

    Hi, I'm using an objective kpi with the option Use calculated values of actual and target to compute score unchecked. This objective kpi has 2 kpi children that don't have values, so the objective KPI should be null too. However it isn't and is rolli