Simple Sorting Question

Hi everyone, I'm new to this groupe as I am Java. I'm trying to write an applet that inputs five floating-point numbers and determines and prints the number of negitive numbers input, number of positive numbers input, and the number of zeros input.
I'm not sure how to 'determine' this, in an array probably? As you'll see from my code I'm lost and confused. Here is my code so far, thanks so much for any help!
import java.util.*;
import java.awt.Graphics;
import javax.swing.*;
public class PosMin extends JApplet {
     int[] numbers = new int[5];
     int[] sortedNumbers;
     double pos1, pos2, pos3, pos4, pos5, neg1, neg2, neg3, neg4, neg5;
     String first, second, third, fourth, fifth;
public void init (){
     first = JOptionPane.showInputDialog ("Enter First Number:");
     second= JOptionPane.showInputDialog ("Enter second Number:");
     third = JOptionPane.showInputDialog ("Enter third Number:");
     fourth = JOptionPane.showInputDialog ("Enter Fourth Number:");
     fifth = JOptionPane.showInputDialog ("Enter Fifth Number:");
     numbers[0] = Double.parseDouble (first);
     numbers[1] = Double.parseDouble  (second);
     numbers[2] = Double.parseDouble (third);
     numbers[3] = Double.parseDouble (fourth);
     numbers[4] = Double.parseDouble (fifth);
public void paint(Graphics g){
}

Hi guys,
I think I'm a little over my head here. I'm trying to do what you're suggesting John, but I'm still unclar on some of the concept behind this code. This is my modified code (which is riddled with errors) that I've been working on all night/day. I'm learning tons from my books about java arrays and the language in general, but still annoyed this doesn't work. I appreicate all help, but I get the feeling I need more :P. Thanks a lot for any help.
Here is my failing code. I ripped out a lot of what I had and i've rewritten it so many times I feel off track, which I'm certain is more than a feeling. Anyone's suggestion is welcome, I can't wait to get this to work.
import java.util.*;
import java.awt.Graphics;
import javax.swing.*;
java.util.Vector;
public class PosMin extends JApplet {
     Vector myNums = new Vector(); //creates an empty vector
     int[] numbers = new int[5];
     int[] sortedNumbers;
     double pos1, pos2, pos3, pos4, pos5, neg1, neg2, neg3, neg4, neg5;
     String first, second, third, fourth, fifth;
public void init (){
int numGreat = 0, numEqual = 0, numLess = 0;
for (int x = 0; x < myNums.size(); x++){
  if ((int) myNums.elementAt(x) > 0)  {
    numGreat++;
  } else if ((int) myNums.elementAt(x) == 0)  {
    numEqual++;
  } else  {
    numLess++;
public void paint(Graphics g){
}

Similar Messages

  • Simple sort question - Numbers '09

    Have a table with a few colums. One is a column of dates and the other of categories.
    Wish to sort the entire table in priority order, first by category, then by date.
    Easy to do in Excel. Am sure Numbers has a way to do this, but can't find it.

    1.
    Verena B.
    44
    Gewicht Verloren
    2.
    Yvonne S.
    41.8
    3.
    Reini K.
    38
    4.
    Martin P.
    35.8
    5.
    Alexandra P.
    35.3
    6.
    Annette E.
    28.5
    7.
    Christine W.
    28
    9.
    Esther H.
    27.5
    8.
    Sascha P.
    26.2
    10.
    Sascha K.
    25.5
    11.
    Rita S.
    23.8
    12.
    Michaela R.
    23.2
    13.
    Alexandra K.
    23
    Top 100
    14.
    Gabriela S.
    22.6
    15.
    Maria C.
    21.1
    16.
    David F.
    21
    17.
    Ellen R.
    20.7
    18.
    Fabienne F.
    20.7
    19.
    Viktor A.
    20.2
    20.
    Rolf W.
    20
    21.
    Ingrid T.
    19.3
    22.
    Diana R.
    19.2
    23.
    Sabine S.
    19.2
    24.
    Elda S.
    18.6
    25.
    Rolf H.
    18.6
    26.
    Chantal V.
    18.5
    27.
    Renè B.
    18.5
    28.
    Ralph W.
    18
    29.
    Barbara B.
    17.7
    30.
    Chris R.
    17.6
    31.
    Inge W.
    17.5
    32.
    Liliane G.
    17.5
    33.
    Reto V.
    17.4
    34.
    Susann M.
    17
    35.
    Ciro A.
    16.7
    36.
    Sabrina B.
    16.6
    37.
    Brent M.
    16.5
    38.
    Jolanda E.
    16.4
    39.
    Alessandro M.
    16.2
    40.
    Ruth M.
    16.2
    41.
    Andrea M.
    16
    42.
    Franz B.
    16
    43.
    Monika S.
    15.9
    44.
    Dominique A.
    15.8
    45.
    Hansjürg G.
    15.7

  • Simple Sort Question

    I know we can sort things using query expressions. But I'd like to put the equivalent of an "ORDER BY" clause in our ORM.XML file for certain entities, to keep the sorting separate from the code. But I don't see a way to do that? Is there?
    Thanks!

    Yep--same conclusion we've come to here. Not sure why they thought it was important for 1-to-N and n-to-m, but not more generally. I guess it's the inherenet Many aspect of those things.
    Thanks!
    There is no default order by, but you can set an
    @OrderBy on a OneToMany or ManyToMany.
    If you use named queries, you can define the order by
    on them in JPQL.

  • Simple/silly question: how do I set/change default font/color for outgoing mail messages?

    Simple/silly question: how do I set/change default font/color for outgoing mail messages?

    Just a suggestion..........
    Download Thunderbird.  Easier to use when it comes to what you want to do w/your emails. 

  • Sorting question over state...

    Hi there,
    Anyone know where you amend the over state / hover of an option in a sorting question ???
    Been looking in the object style manager but can't find it in there...
    Thanks in advance...

    You are talking about the partially transparent grey bar that appears when hovering over an answer in the Sequence type of questions. There is no style that can be customized AFAIK. It is not even changing with the included themes. Same is valid for the connecting lines in matching questions that are always black, color cannot be changed for them neither. It is a pity, would recommend you enter a feature request to be able to customize the color of both the hover bar and those lines.
    https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    Lilybiri

  • 4 Simple Flash Questions that Are Stumping Me!

    What is the Frame Rate for Web Animations
    Q1. I am making an animation which will be played on the web. What is the default frame rate (fps) of Flash CS5? And what is the frame rate of for web?
    Q2. My animation needs to be 30 seconds long. So at 15 fps that would mean I need to use 600 frames in Flash?
    How Do I Mask everything so all I see is the Content on the Stage?
    I have a wide image that extends past my movies stage size so when I preview my movie the image is visible. How do I mask out anything that extends past my movies window size? I believe I can create a layer named "mask" and place it above all other layers, but I forget how to make the mask. Any help is appreciated.
    How to Fade a Graphic
    I have a graphic element (some type) and I want it to fade from 0% to 100%. In older versions of Flash I could just select the symbol and then set it's alpha value to 0%, move a few keyframes and then set the alpha to 100%. Voila! but now it doesn't seem to work that way. How can I do this in CS5?

    Ned, it says 24 fps which means there is 24 frames per second so each 24 frames is 1 second.
    Date: Fri, 4 Nov 2011 05:35:16 -0600
    From: [email protected]
    To: [email protected]
    Subject: 4 Simple Flash Questions that Are Stumping Me!
        Re: 4 Simple Flash Questions that Are Stumping Me!
        created by Ned Murphy in Flash Pro - General - View the full discussion
    1 You can create your character as a movieclip and copy/paste that movieclip from one file to another. 2. One way to create a movieclip is to copy all the frame of the animation's timeline (select them all, right click the selection, choose Copy Frames), then create a new movieclip symbol (Insert -> New Symbol...etc) right click on its only keyframe and chhose Paste Frames.  THat will put all the layers and frames you copied into the movieclip The only way to come close to being certain about the timing of you animation is to use code to keep track of the time, something like getTimer()..  The frame rate that a file plays at is not a reliable means of dictating the time it takes due to a variety of factors which include the amount of content you are trying to process and performance limits of the user's machine.
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4007420#4007420
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4007420#4007420. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Flash Pro - General by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Simple performance question

    Simple performance question. the simplest way possible, assume
    I have a int[][][][][] matrix, and a boolean add. The array is several dimensions long.
    When add is true, I must add a constant value to each element in the array.
    When add is false, I must subtract a constant value to each element in the array.
    Assume this is very hot code, i.e. it is called very often. How expensive is the condition checking? I present the two scenarios.
    private void process(){
    for (int i=0;i<dimension1;i++)
    for (int ii=0;ii<dimension1;ii++)
      for (int iii=0;iii<dimension1;iii++)
        for (int iiii=0;iiii<dimension1;iiii++)
             if (add)
             matrix[i][ii][iii][...]  += constant;
             else
             matrix[i][ii][iii][...]  -= constant;
    private void process(){
      if (add)
    for (int i=0;i<dimension1;i++)
    for (int ii=0;ii<dimension1;ii++)
      for (int iii=0;iii<dimension1;iii++)
        for (int iiii=0;iiii<dimension1;iiii++)
             matrix[i][ii][iii][...]  += constant;
    else
    for (int i=0;i<dimension1;i++)
    for (int ii=0;ii<dimension1;ii++)
      for (int iii=0;iii<dimension1;iii++)
        for (int iiii=0;iiii<dimension1;iiii++)
           matrix[i][ii][iii][...]  -= constant;
    }Is the second scenario worth a significant performance boost? Without understanding how the compilers generates executable code, it seems that in the first case, n^d conditions are checked, whereas in the second, only 1. It is however, less elegant, but I am willing to do it for a significant improvement.

    erjoalgo wrote:
    I guess my real question is, will the compiler optimize the condition check out when it realizes the boolean value will not change through these iterations, and if it does not, is it worth doing that micro optimization?Almost certainly not; the main reason being that
    matrix[i][ii][iii][...]  +/-= constantis liable to take many times longer than the condition check, and you can't avoid it. That said, Mel's suggestion is probably the best.
    but I will follow amickr advice and not worry about it.Good idea. Saves you getting flamed with all the quotes about premature optimization.
    Winston

  • Simple sorting program for folders/files

    Hello comunity,
    I would like to make a simple sorting program which will scan through some folder looking for files with different extensions. Then copy files of the same format (example *.pdf) and (create) place them into folder with the name of the extension. After that the program (script) should look for another extension and do the similar operation to them untill all files will be moved. I am new to applescript and automator.app, so could you please put me on the right direction which programmin (script) language should I use. Sample code and good tips would be usefull too. Thank you for your time.

    This is not a hard thing to do. If you want to write it yourself, and have some background in programming, I recommend to read a book on AppleScript and start writing the code in AppleScript Editor.
    The AppleScript Language Guide is a free reference book by Apple which you can download it. There are a lot of sample codes on the net too.
    You should use the Finder dictionary to do this work. Finder is a scriptable application in Mac, which has a dictionary. This dictionary describes about the objects inside the finder that do all the duties of the Finder and you can call them directly in AppleScript to automate things. Open AppleScript editor, go to Window > Library and double click on Finder. This will open the dictionary. Note that all the objects in scriptable applications have a hierarchical relationship, starting from the root "application" object. You can read the dictionary to get familiar with the objects in the Finder app and know how to use them.
    Here is some code:
    tell application "Finder"
      tell the front window
      log (count of items of it)  -- prints the count of items in the window
      make new folder in it with properties {name:"mani"} -- makes a new folder named: mani
      make new file in it with properties {name:"test", extension:"txt"} -- makes a new text file
      repeat with x in every file in the items of it
          log the name of x
      end repeat
      end tell
    end tell
    If you can program in Objective-C and not have enough time to learn AppleScript, you can use Scripting Bridge technology to automate scriptable applications using Objective-C. This is so much better because enables you to debug your code or execute it line by line, which is not possible when working with AppleScript Editor.
    Hope this helps

  • A few simple Logic questions...please help.

    I have a few probably simple Logic questions, that are nonetheless frustrating me, wondering if someone could help me out.
    1. I run Logic 8, all of the sounds that came with logic seem to work except organ sounds. I can't trigger any organ sounds (MIDI) on Logic, they won't play. I have a Yamaha Motif as my midi controller.
    Any idea why?
    2. I've starting running into a situation where I will record a MIDI track, the notes are recorded but they won't playback. The only track effected is the one that was just recorded. All other midi tracks playback.
    I have to cut the track, usually go out of Logic and back in, re record for it to playback properly. Any idea why this may be happening?
    3. How important is it to update to Logic 9. Are there any disadvantages down the road if I don't upgrade. If I purchase the $200 upgrade, do I get a package of discs and material, or it just a web download.
    Any help is appreciated!
    Colin

    seeren wrote:
    Data Stream Studio wrote:
    3) You get a full set of disks and manuals.
    They're including manuals now?
    I think his referring to the booklets ...on how to install etc
    It would be great to see printed manuals though ...I love books especially Logic/Audio related !!
    A

  • Simple Quick Question

    wrong section, post was moved.
    Message was edited by:
    Rob17

    you titled "simple quick question"...
    .. complicated to answer..
    a) the TermsOfUse of the iTS don't allow any processing of purchased files, these are "copy protected"..
    b) iM has a voice-over function..
    c) iM is a video-edit app.. easy to use... just learn to handle it...
    d) iM allows to "extract" audio (=muting the original audio, adding your own..)
    e) to learn iM, spend some time here: http://www.apple.com/ilife/tutorials/imovie/index.html
    f) use pencil and paper first! WRITE and scribble, what shall happen when in your movie/parody... make a script, draw a storyboard .. THEN launch iM.. in other words: think first, then edit.. iM is just a tool, it does not "create"... Picasso needed a papertowel and half a stencil to create art....
    g) to get comfortable with iM, start with your own, small, short (3min!) project... import some stills, edit them, add a funny voice-over, add sounds, add music... good? make a bigger one...
    h) .. in our Lecture II, we teach you how to import shows from TV, youtube, wherever..
    standard disclaimer:
    be nice to ©opyrights ...

  • Simple query question

    hi all,
    I have a XMLType table with one column - I have presently one row, in my column xmlsitedata I have stored one large xml file.The schema definition is given below:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    - <xs:element name="siteList">
    - <xs:complexType>
    - <xs:sequence>
    <xs:element name="site" type="siteType" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    - <xs:complexType name="siteType">
    - <xs:sequence>
    <xs:element name="nameEn" type="xs:string" />
    <xs:element name="nameFr" type="xs:string" />
    </xs:sequence>
    <xs:attribute name="code" type="xs:string" />
    </xs:complexType>
    </xs:schema>
    I have executed the query below:
    select x.XMLSITEDATA.extract('/siteList/site/nameEn/text()').getCLOBVal() "stName" from wsitelist x;
    and I get all english names of some 200 locations, however, there is 1 row selected and all names show up on one row. How do I split them into 200 or whatever rows?
    Thanks,
    Kowalsky

    Have a look at the answer provided in the following thread.
    very simple XML question
    This may solve your problem.
    use xmlsequence.
    Alvinder

  • Simple Report Question

    Post Author: scott123
    CA Forum: General
    I want to take the information in a simple excel table and recreate it 3 times, each time sorting/grouping on a different columnHere is the tableAnd here is the report that I'm trying to generate (first sorted by name, alphabetically, then grouped by rank, then grouped by size) I'm comfortable working with excel tables in Crystal, but I'm running into a problem repeating the information and then sorting each group separately. I also have no problem doing each group in a single report (without repeating any records), but I'd like to include all 3 groups in a single report.  My apologies for how remedial this question is- I thought for sure that Crystal could do this easily but I've spent a couple of days on this and am running into a brick wall.

    Post Author: pandabear
    CA Forum: General
    That's right Scott, and maybe make them "on demand"
    sub reports so the user only has to see the data they
    really want at the moment.  Gives the report a nice clean look too.
    PB

  • Simple Router Question (except not simple for me)

    (Couldn't find another place for this question so I put it here.)
    I have a router between my broadband modem and my Macs on the blink. I want to get a new one. I'm not asking for product recommendations as much as terminology clarification.
    Again, I need a box that accepts my ethernet cable coming out of my broadband modem. I don't need wireless. It's simply going to allow me to offer ethernet cables out to Airport Express, iMac, etcetera.
    What am I precisely looking for?
    An ethernet router? Splitter? Does it need to have some sort of high bandwidth? The thing is I see these produces vaguely named and prices all over the place. A simple ethernet 'hub' strikes me as something very cheap ($20-30).
    Any help truly appreciated.

    Unless your broadband modem is "Also" a router, you need a router.
    The Airport Express is a router, but it takes the ethernet cable and provides routing services for WiFi devices. It will not provide additional ethernet services for other devices.
    You can NOT use an ethernet switch nor an ethernet hub.
    While you can get ethernet only routers, the chances are that you will pay a premium over just getting a WiFi base station.
    A WiFi base station is mostly a commodity items so they are often very inexpensive.
    If you really do not need the WiFi services, many WiFi base stations allow you to turn off the WiFi.
    Also note. If you are going to use the Airport Express to provide your WiFi, then you should configure it so it is in "Bridge" mode, otherwise you will have multiple isolated subnets where the devices on WiFi will not be able to properly see the devices on your ethernet. Putting the Airport Express in "Bridge" mode makes the WiFi network part of the same subnet that the ethernet devcies are on.

  • Dreamweaver Simple Table Question

    So I have several tables,  100 rows, 5 columns for my data.  Here is my question, Is there a way to flip the table, so data at top goes to bottom and bottom to top.  All my data runs from old to new, when i want it new to old.  I know you can do this in excell by alphabet or date, id there a way in DW

    Someone else may correct me if I am wrong but I am pretty sure you cannot sort a column or row of values in an html table using DW. What you could do is create your list in Excel, sort the list in Excel, and copy the table range and paste it in DW, which will create a perfect html table. You can also copy and paste from Dreamweaver to Excel but it's not as simple. You would have to copy and paste just one column at a time and you will have an extra empty row for each populated row.
    Another solution is to create a mySQL table that can be easily sorted and use PHP to display the table on your page. You would have to know at least the basics of mySQL and PHP to do this, but if are going to constantly add new records to your table, mySQL would be your best solution. If your table is static, the first solution will work fine.

  • A simple security question

    I'm trying to write a simple self-signed applet that use a jca provider but thi exception "java.security.SecurityPermission putProviderProperty.BC" is thrown. if I use a policy file, it works fine but for a beginner user is not very useful intall a new policy file.
    After this I tried to write a new self-signed applet that read a file and open a ServerSocket on port 21, and it work fine without a new policy file!
    My question is this: why is needed a policy file to add a provider and not to open a ServerSoket or read/write a file???????
    PS
    if u have an idea to resolve my problem without a policy file, tell me pls!!! IT'S URGENT!!

    An applet works out of a so-called sandbox. The security restrictions can be overcome in one of two ways that you have tried:
    1) by the use of a policy file, or
    2) by signing the applet
    So, to answer your question:
    My question is this: why is needed a policy file to add a provider and not to open a ServerSoket or read/write a file???????Since the applet is signed, there is no need for a policy file......if you tried to access the socket without signing the applet, you'll get the security exception!
    ;o)
    V.V.

Maybe you are looking for

  • How to restrict the entry of same material twice on the order

    HI, How to restrict the entry of same material twice on the order before saving the Order ? I do not want my users to enter the same material as two different line items in the order. Any inputs wud b appreciated

  • Acrobat Pro 9 & iPad pdf reader issues

    When I create/edit a pdf in Acrobat 5 and then send to my iPad, the pdf will be complete and correct.  When I create/edit the same pdf in Acrobat 9 Pro and send it to my iPad the pdf will be missing any data that I edited and the other text will be g

  • Bex Analyzer doesn't work

    Dear All, When I try to run the BeX Analyzer, either from Start->Business Explorer->Analyzer or from RRMX transaction, I can't open any queries/workbooks and I see all the icon in German. The other components (Query Designer, Report Desinger) and the

  • Tax procedure compatability in different countries

    Hi All, Can we have two companies (Company codes) operating in differeng countries under same client? We are operating in India, can we have another subsidiary say in Spain within same Client? And is the Tax Procedure Company Code specific or Client?

  • IIS proxying to Weblogic

    Guys is there any detailed step by step on how to make iis proxying to weblogic server? Thanks in advance