How can I measure the length of a 2D array?

The grades [] [] is a 2D array and i want to return the length of the second dimension, that is 8.
And grades[].length doesn't work, so what's the problem?
Thanks!!!!!!!!
  static String [] [] grades={{"A","B","B","D","D","C","A","F"},                         
                                               {"F","B","C","B","A","D","B","B"},
                                               {"C","C","E","E","F","C","B","A"},
                                               {"C","D","E","D","B","C","D","E"}};
     static int marks [] []=new int[grades.length] [grades[].length];  // why doesn't it work??

static String [] [] grades={{"A","B","B","D","D","C","A","F"},                         
                                               {"F","B","C","B","A","D","B","B"},
                                               {"C","C","E","E","F","C","B","A"},
                                               {"C","D","E","D","B","C","D","E"}};
static int[][] integer_grades=convertToInt(grades);
static int[][] convertToInt(String[][] grades)
int[][] grade_ints = new int[grades.length][];
for (int j=0; j<grades.length;j++)
       grade_ints[j]=new int[grades[j].length];
       for (int k=0; k<grades[j].length; k++)
                grade_ints[j][k]=convertToInt(grades[j][k]);
return grade_ints;
static int convertToInt(String s)
   if (s.equals("A")) {return 5;}
   else if (s.equals("B")){return 4;}
   else if (s.equals("C")){return 3;}
   else if (s.equals("D")) {return 2;}
   else if (s.equals("F")) {return 1;}
   return 0;
}Should work--didn't test it though..wrote it in a hurry...

Similar Messages

  • How can I measure the hertz in a wave form?

    How can I measure the hertz in a wave form?

    As an example, this is from BBC Technical Requirements for HD material:
    3.1.1 Stereo line-up tones
    All stereo tracks must use EBU 1KHz tone (left ident). All tones must be sinusoidal, free of distortion and phase coherent between channels.
    Digital Audio Reference level is defined as 18dB below the maximum coding value (-18dBFS) as per EBU recommended practice R68.
    See also:
    http://www.bbc.co.uk/guidelines/dq/pdf/tv/tv_delivery_to_network_programmes_v1.2-2011.pdf
    for full document.
    And for BBC Radio:
    Not every Network requires tone. Check the delivery requirements with the commissioning network or click here.
    Reference tone, where used, should be at -18dBFS or PPM 4 on A, B and/or M.
    If submitting material with reference tone, tone and programme material must be have been monitored and measured through the same technical chain. The level of the tone must be equivalent to 0dBu and no less than 8dB below peak audio level for the programme material.
    THE LEVEL OF TONE MUST HAVE A KNOWN RELATIONSHIP WITH THE LEVEL OF THE PROGRAMME MATERIAL AND THIS MUST BE STATED; for example: “Tone at 8dB below peak programme level”.
    As a newcomer to digital sound (my background is camera) I confess to being somewhat confused. We are normally told to record at the highest level possible. So for voice podcasts I tend to record at about -6dB below peak for maximum volume, distributeds on MP3 files.
    But I can underatand that televison and radio especially for analogue transmission) may have limited headroom, hence the requirement for -18dB peak = 0dBM.
    I remember when we first rented out Digital Betacam cameras, some recordists were recording almost everything OVER -18dBM.
    I suspect that until we have an all-digital world, these requiremnents will still be in place.
    Many thanks to all. It's a ghreat community!
    Brian Rose

  • How can I adjust the length of a note? Please help.

    How can I adjust the length (the sustain time) of a note after I have selected the note? Many thanks.

    Just drag the right end back and forth (mouse over the end of the note - a ] appears) - by holding down ctrlshiftdragging you can change the subdivision into ticks. In the Midi event editor you can do it numerically - just change the numbers displayed in the length section.

  • How can i change the length of a narration ?

    how can i change the length of a narration ?

    hotts77
    Thanks for the reply.
    Still not sure what version of Premiere Elements that you are using. But, the following should apply nonetheless
    What you describe is what I have described in my blog post and for which I have discussed all aspects of the issue. There
    is no workaround to force the program to give you more than you are getting now without other clips also on the track(s). The
    blog post just about says it all.
    You might have to weigh the pros and cons of
    a. Recording your narrations as .wav files in a free audio editor such as Audacity
    Audacity: Free Audio Editor and Recorder
    and then importing those into your Premiere Elements project with Premiere Elements' Add Media/Files and Folders/Project Assets from where you drag the narration to the Narration Track.
    b. Put any video clips on the Timeline when you are recording your Premiere Elements narrations with its Narration Tool. Then remove these video clips and replace them with the real thing when you are ready to put narration and clips into the project.
    Please let me know if you are OK with the details.
    Thank you.
    ATR

  • How can I know the length of the image data section of a PSD file

    I'm a C++ programmer developing a project to parse PSD files, and it's necessary to know whether there is a length field indicating the length of the image data in image data section of a PSD file, if not, how can I know the length?
    Thank you.

    Sorry I can't help, maybe there is some information in the SDK?
    http://www.adobe.com/devnet/photoshop/sdk.html
    Or someone might be able to help in this forum?
    http://forums.adobe.com/community/photoshop/photoshop_sdk

  • How can I shorten the length of my ringback tone?

    How can I shorten the length of my ringback tone?

    You mean music that the caller hears when they call you? You'll have to contact your carrier. That's a carrier feature, not a function of the phone.

  • How can I measure the Graphics Card usage? I.e. percent load

    Hello,
    How can I measure the Graphics Card usage, like with the processor in Task Manager, but instead giving a percentage usage for the graphics card instead? Is there an easy way to do this, or would it require a lot of code? Is it even possible?

    Ah, so It's unlikely that Java3D will include anything for reading this data then? I was really aiming at measuring the GPU usage under this API which although i have limited knowledge using, I do at least have some knowledge - I wouldn't have a clue how to access any other API's!
    I'm using an NVidia TNT2 card at the moment, which is quite old.

  • How can i measure the speed of the fan in sound and vibration signal simulator box

    how can i measure the speed of the fan in sound and vibration signal simulator box
    provided the values  tach out:2 pulses/revolution and  maximum speed = 6000rpm

    Hi. I tried your suggestion and I could not get it to work well. In
    fact it worked better without the running average (which suprised me).
    I also played with the number of data points but still could not get it
    to work well.
    Do you have any other suggestions on how I could sort this problem out?
    I
    have attached a screen shot of the signal. To recap, I'm trying to
    measure the'y' position of the flat regions of the signal. The signal
    does not have a constant level, so this 'y' position varies with time
    in a non-unform manner.
    I am currently differentiating
    the signal and selecting the y position when the differential is equal
    to zero (within a tolerance band).
    In the screenshot, the
    signal has been zeroed using the method I have described above.
    However, it occasionally has glitches which may be caused when the code
    picks up a zero gradient at a peak or valley in the signal.
    I therefore need some kind of algorithm that only measures the position of the flat regions.
    Many thanks
     John
    Attachments:
    screenshot.gif ‏121 KB

  • How can I measure the copy speed of my compact flashcard to folder?

    how can I measure the copy speed of my compact flashcard to folder?
    I dont have a stop watch.

    Hi Steve Zavodny;
    Generally compact flash cards or basically slow because of them being flash memory and USB. What are you after here?
    Allan

  • How can i select the length of a trace in Ultiboard?

    Hello
    i got a problem with the length of some traces.
    Some special traces need to get the same length.
    I used the group edit item to create a grout with the needed nets.
    How can i creat the traces now. When i use the item Follow-me it doesn't apply the selected value.
    At least i tryed to use the Autoroute function but this just function doesn't work. (Error during autorouter preprocessing. Source: Autorouter Parameter Error)
    Is there any smart possibility to handle the problem?
    Best regards

    Beboni007,
    Here is how matched length traces can be completed in Ultiboard.
    First you do not necessarily need to setup a part group to do this... (differential pairs would require grouping)
    1. Forward annotate your schematic / netlist from Multisim.
    2. Determine the absolute minimum routing length from the origin of the net to the destination by routing a starter trace (remove/undo).
    3. In Ultiboard, go to the spreadsheet view/ Nets tab and set the 'Topology' of interest to 'Star' for the traces you need matched.
     -> This changes the Max Length and Min Length in the Nets tab from N/A to a number allowing you to set the min/max trace length
    4. Set the Min Length of the nets to an appropriate value for your application (it will need to be at least the value of your starter trace in step #2)
      -> Set the Max Length to the minimum + 50 mils or so (Ultiboard will do a relatively good job at attaining the minimum value but give it some room)
    5. Go to the Autorouter/place settings and set the Routing mode to: Gridless (this will give the router flexibility to go off grid and match lengths)
    6. Highlight the traces of interest and Autoroute these (Autoroute -> Autoroute Selected Nets).
    Some Tips:
    a. Do this routing first if possible
    b. Restrict routing to a single layer if possible (restrict routing layers -> Routing Layers in the Nets tab)
    Here is a simple example in Multisim: 
    After autorouting in Ultiboard as described:
    Hope this helps,
    Regards,
    Patrick Noonan
    National Instruments
    Attachments:
    Matched Lengths.zip ‏44 KB

  • How can i get the length of a string with Simplified Chinese?

    when i use eventwriter to add content to a xmldocument,there are some chinese simplified string in it,i use String.length() for the length ,but it is not correct~how can i get the right length for eventwriter?

    Below is a simple patch for this problem. Using this patch you need to pass 0 as the length argument for any XmlEventWriter interfaces that take a string length.
    Regards,
    George
    diff -c dbxml-2.3.10/dbxml/src/dbxml/nodeStore/NsEventWriter.cpp dbxml-2.3.10.patch/dbxml/src/dbxml/nodeStore/NsEventWriter.cpp
    *** dbxml-2.3.10/dbxml/src/dbxml/nodeStore/NsEventWriter.cpp    Fri Nov  3 12:26:11 2006
    --- dbxml-2.3.10.patch/dbxml/src/dbxml/nodeStore/NsEventWriter.cpp      Thu Mar 15 13:58:13 2007
    *** 234,239 ****
    --- 234,241 ----
            CHECK_NULL(text);
            CHECK_SUCCESS();
    +       if (!length)
    +               length = ::strlen((const char *)text);
            if (!_current)
                    throwBadWrite("writeText: requires writeStartDocument");
            try {
    *** 413,418 ****
    --- 415,422 ----
            CHECK_NULL(dtd);
            CHECK_SUCCESS();
    +       if (!length)
    +               length = ::strlen((const char *)dtd);
            if (_current) {
                    if (!_current->isDoc())
                            throwBadWrite("writeDTD: must occur before content");
    diff -c dbxml-2.3.10/dbxml/src/dbxml/nodeStore/NsWriter.cpp dbxml-2.3.10.patch/dbxml/src/dbxml/nodeStore/NsWriter.cpp
    *** dbxml-2.3.10/dbxml/src/dbxml/nodeStore/NsWriter.cpp Tue Jan  2 16:01:14 2007
    --- dbxml-2.3.10.patch/dbxml/src/dbxml/nodeStore/NsWriter.cpp   Thu Mar 15 13:59:25 2007
    *** 326,331 ****
    --- 326,333 ----
                    needsEscape = false;
            else
                    needsEscape = true;
    +       if (!length)
    +               length = ::strlen((const char *)chars);
            writeTextWithEscape(type, chars, length, needsEscape);
    *** 336,341 ****
    --- 338,345 ----
                                  bool needsEscape)
            if(_entCount == 0) {
    +               if (!len)
    +                       len = ::strlen((const char *)chars);
                    if ((type == XmlEventReader::Characters) ||
                        (type == XmlEventReader::Whitespace)) {
                            char *buf = 0;
    *** 381,386 ****
    --- 385,392 ----
      NsWriter::writeDTD(const unsigned char *data, int len)
            if(_entCount == 0) {
    +               if (!len)
    +                       len = ::strlen((const char *)data);
                    _stream->write(data, len);
      }

  • How can I know the length of an array in the class?

    hard to express, I show guys an example:)
    public class code{
    pblic String[] str; // String array
    public test () {
    // I hope to print all items in the array after initiation;
    // e.g. if String[3] , then print str0, str1,str2; if String[4], then //print str0, str1, str2, str3;
    My puzzle here is, since the "str" may be not the same length in different initiation of code object, how can I implement the test method to print all items

    for (int i = 0; i < str.length; i++)
      System.out.println(str);

  • I DRAG AND DROP A VIDEO CLIP FROM THE EVENT BROWSER THAT IS 7.9 SECONDS INTO MY IMOVIE I'VE STARTED AND IT CHANGES IN THE PROJECT TO 4.9 SECONDS - HOW CAN I KEEP THE LENGTH THE SAME

    I drag a video clip from Event to Project into my imovie I've started.  The video clip length changes from 7.9 seconds to 4.9 seconds. How can I stop that length from being changed?

    If you are using transitions either side of the clip they will use some of the clip to generate the effect, there isn't anything you can do unless you remove or shorten the transition.
    If you aren't using transitions it may be that you are only selecting part of the clip in the event window, try dragging out the yellow frame to include all the video you want in the project.

  • How can I change the length of multiple lines at the same time?

    This just seems like it should be a no-brainer, but obviously for me it isn't.  I'm trying to change the length of multiple lines, that are at different angles, at the same time, in CS4.  Basically, I design the face of dials used for airplane instrument gauges (like RPM, Torque, etc), and they have gradiation marks (lines) located all around, similar what a clock looks like with the hour and minute gradiation marks (lines).  Is there a way to select all the lines, that I know are the same length, and change it to a different length, that's accurate to the 1/100th of an inch?  It would just be like selecting multiple lines that have all the same stroke, then using the stroke box to change the stroke weight from .025in to .030in.
    I've used the transform box to change the 'height' of a line before, but the line has to be at 90 degrees (straight up and down), and that won't work for the lines that are at, say, a 45 degree angle.
    I hope i'm explaining this in a way that someone will understand. If not, I can sure try to clarify more, or insert the picture so you could see what i'm talking about.
    Thanks for any help you can give!

    OK, after fiddling around with everyone's ideas, I think I finally got it. I knew there had to be something with proportions between W and H, but couldn't figure out the math, until Jacob answered with:
    "If each line must be strecthed from the inner/outer end, you may select each and use the Transform palette, choosing the right Reference Point, multiplying by the proportion in W or H (1.75/1.5), and Ctrl/Cmd clicking."
    Now, I basically did everything above, (but I couldn't figure out what you were talking about with the Ctrl Clicking thing), except after figuring out the right proportion (which ends up being so small you guys would die if I told you the number; the numbers I gave earlier were just an example and much larger than what i'm really working with) I just clicked the little chain next to the W and H boxes to constrain the proportions. I then put the new number (multiplied proportion by whatever was in W) in the W box. The line lengthened perfectly toward the center of the dial, keeping the correct angle!
    And Harron-Thanks for the link to Teri's, It is going to help with some things I do, but most of the dials I design don't have equal distances between each gradiation mark, and the blueprints I work off of usually have exactly what distances that the grad. marks are supposed to be. So, after selecting one of my grad marks that is already at it's correct place, I then use the rotate tool and Alt-Clicking the very center of the dial, I can then put in exactly what distance I want the next grad. mark to be at, I hit copy (instead of OK) and there will be a new grad. mark exactly the correct distance from my original. Then if I want to have the 3rd grad. mark I just hit Ctrl-D and it will copy another mark to the next position. I don't know if you necessarily wanted to know all that, but i thought i'd explain why I like doing it that way.
    A BIG thanks to everyone! I'm really a AI newbie and am the only one at my company that knows how to use it, so I don't have anyone close to ask stupid questions to. So I appreciate all your help!

  • How can i get the length of a DefaultTreeModel

    i got a tree structure (DefaultTreeModel), now i want to know how many level of this tree, what method can i call to get the length of the tree???

    What sort of TreeNodes do you have in your Tree? If you have DefaultMutableTreeNodes in there then you could call the getDepth method on the root node. That operation is expensive though.
    Good Luck
    Lee

Maybe you are looking for

  • Sharing with the wife (NOT sharing the wife!)

    I would like to have a common shared address book and calendar with my wife. Here's the history... Have had a .mac/MobileMe/iCloud account all the time on my home Intel iMac (running Lion) and iPhone 3G/4 and iPad 2. I gave my wife my old iPhone 3G w

  • Unable to create new rows in master detail

    Hi, I am new to ADF I am using Jdeveloper 11.1.1.6, I have two tables customer and contacts, customerId is a foriegnKey in contacts. when customer is deleted all the contacts need to be deleted. I have created an association (1 to * customer to conta

  • The bottom of my macbook is falling off how do i fix this and how much does it cost?

    the bottom of my macbook is falling off how do i fix this and how much does it cost?

  • Float do double convertion problem

    Hello! I have code: Float f=new Float(1.68f); double test1 =f.doubleValue() * 33333360; double test2 =1.68D * 33333360; System.out.println("test1: "+test1); System.out.println("test2: "+test2); Output is: test1: 5.600004305159569E7 test2: 5.60000448E

  • Driver for Canon MPC190

    I cannot find a print driver for the multi machine (scan/print/copy) Canon Smartbase MPC190 (not on Canon support nor on Apple). Apperantly it doesn't exist. Would there be anybody out there knowing about a developped driver for this, or if any other