Problem printing the output

i'm writing a getClassMean() which is going to compute the Mean score of the whole class. in the following myLines is a ArrayList object that stores each String from my input file, which look something like:
Stevens, Frank, Z.; 87, 86, 92, 78, 86
Franklin, Susan, A.; 98, 88, 94, 98, 95
Bowers, Brett, B.; 85, 78, 83, 84, 89
This is the method in the Mean class:
protected ArrayList<Double> classGrades = new ArrayList<Double>();
public double getClassMean(){
            String gb;
            String[] array, grades;
            double mean;
            double score;
            for(String l : myLines) {
                array = l.split("; ");
                gb = array[1];    //gb --grade block
                grades = gb.split(", ");
                for(String scoreStr : grades ) {
                    score = Double.parseDouble(scoreStr);
                    classGrades.add(score);
            double sum = 0.0;
            for(double d : classGrades) {sum += d;}
            mean = sum / classGrades.size();
            return mean;
        }and the Driver program has this:
Mean m = new Mean();
double classMean = mean.getClassMean();
System.out.println(classMean);but the output print something i don't understand:
NaN
can someone tell me what's going on? thanks!

NaN is "Not a Number" it comes from doing operations with undefined results, like 0.0 / 0.0 .
Print out sum and classGrades.size() before doing that division, then trace backwards (add more print statements if you need to) to find your bug.

Similar Messages

  • Any means to print the output from an abap report immediately

    Hi,
    I would like to know if there are any means to print the output of an abap program immediately. Our user wants to execute the program online and once the result list is displayed on screen, user wants the same list to be printed simultaneously without the need to press the 'Print' button.
    Thanks in advance for your help and advises.
    Francis

    Hi
      We can print the list while displaying using NEW-PAGE PRINT ON.
      below is the syntax for this.
         NEW-PAGE PRINT ON [NEW-SECTION]
                    [<params> | PARAMETERS <pripar>]
                    [ARCHIVE PARAMETERS <arcpar>]
                    [NO DIALOG].
    Regards
    Ramanjaneya Reddy.
    [email protected]

  • How make "Scanner" not printing the output in a new line?

    Hi!
    I'm Jordi from Barcelona and I'm new on Java and on this Forum. I have a question to you. I'm developing a testing application that uses the "Scanner".
    Before using it, the app asks a question to the user:
    String strInput;
    Scanner sc = new Scanner(System.in);
    System.out.print("* Please, write your name: ");
    strInput = sc.next();Running this, the app asks me for the options and after pressing "Enter" prints the input string in a new line like this:
    * Please, write your name:
    Jordi
    And I would to get the next:
    * Please, write your name: Jordi
    Does anybody know how to make the "Scanner" print the output in the same line as the question?
    Thanks for your help!
    Jordi

    Running the code,
    import java.util.Scanner;
    public class Test {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            System.out.print("* Please, write your name: ");
            System.out.println("* Hi, "+sc.next());
    }results in the following output:
    * Please, write your name: Bart
    * Hi, BartWhere the first "Bart" is the input I gave.
    If this is not the case, then it has something to do with your IDE or perhaps you didn't recompile and it previously was
    System.out.println("* Please, write your name: "); // println instead of printbut it's all guesses.
    Good luck.

  • How to print the output of the screen in Dialog Programming

    Hi,
    Could anybody help how to print the output of a screen in the dialog programming. i can select 'Hard Copy' option in the 'Custumizing of Local Layout' Icon in the standard tool bar. but that prints the whole screen with the toolbar. i want to print only the output which is displayed on the screen. Please help..
    Regards,
    Swathi

    Hi Swathi,
        Ok. Do One thing. Go to menu bar and select Systems -> Own pool Request -> here you get the spool number. Select it and select the option "Print Directly" in tool bar.
    Thanks.

  • Runtime.getRuntime().exec hangs and doesn't print the output

    Hi,
    I have written the following code to execute the command "psexec ipaddress -u userid -p password -l -c execute.exe >> c:/25_showoutpout.txt" and print the output in 25_showoutpout.txt file.
    import java.io.*;
    public class ExecTest{
         public static void main(String args[]) throws IOException{
         String args1 = "psexec ipaddress -u userid -p password -l -c execute.exe >> c:/25_showoutpout.txt";
         try{
         Process p=Runtime.getRuntime().exec(args1);
    int i = p.waitFor();
         System.out.println("Done.with time "+i);
         }catch(Exception e){
              System.out.println("The error is "+e);
    But this program hangs and creates a blank 25_showoutpout.txt file.In the process list I can see the process running, but it doesn't redirect the output in the txt file.When i run the command from the command line it runs fine.Please help me.
    Thanks in advance

    Hi,
    I have written the following program to get the output.But still the required output is not coming in the console file.Only the messages that gets printed in the parent console that is coming in the file.But the expected output is to get the messages from the child window which gets executed while the .exe runs.
    import java.io.*;
    public class RuntimeExecTest{
    public static void main(String args[]){
    String s = null;
    String result= null;
    int count =0;
    try{
              // read the output from the command
    String cmd = "cmd.exe /c D:/installer/PsTools.zip/PsTools/psexec.exe ipaddress -u userid -p password -l -c excute.exe >> C:/RuntimeExec_25.txt";
         Process p = Runtime.getRuntime().exec(cmd);
         InputStream is = p.getInputStream();
         // Get the std in to the process.
         OutputStream os = p.getOutputStream();
         // Get the std err from the process.
         InputStream es = p.getErrorStream();
         // Create readers for those streams.
         BufferedReader reader = new BufferedReader(new InputStreamReader(is));
         BufferedReader errReader = new BufferedReader(new InputStreamReader(es));
         String line;               
         // Read STDOUT into a buffer.
         // If no STDOUT check STDERR.
         while((line = errReader.readLine()) != null){
              // Do something with data here if you wish.
         System.out.println( line );
         while((line = reader.readLine()) != null){
              // Do something with data here if you wish.
         System.out.println( line );
         System.exit(0);
    catch( Exception ex )
    ex.printStackTrace();
    }

  • I am using Firefox ver. 3.0.19 and I have Windows 7. When I use Firefox as a browser I cannot print my emails. I get an error message: "pcfax not availabe". If I use IE I have no problem printing the emails.

    I am using Firefox ver. 3.0.19 and I have Windows 7 which came with a new computer. When I use Firefox as a browser I cannot print my emails. I get an error message: "pcfax not availabe". If I use IE I have no problem printing the emails.
    == This happened ==
    Every time Firefox opened
    == From day 1 with the new computer about two weeks ago.

    It sounds like you have the wrong printer selected.
    When you get the Print window, pick another printer from your printer dropdown. You seem to have a fax printer selected instead of a physical printer.

  • Problem in printing the output !

    I have around 45 fields to show in the output !
    i have given linesize 1023 because i have to get the output horizontally.
    but still i am not able to  adjust.
    IS there any other way so that I can customize my print out

    Friend,
    My answer is available for this problem in this thread...
    https://forums.sdn.sap.com/click.jspa?searchID=-1&messageID=4317216
    Goto Se11
    In the datatype give TBLISTBR (it is a standard element, it will ask you access code for changes)...
    go into change mode...
    in the value range ...change teh upper limit as 2000....
    save and activate
    now go into menu utitilities->setttings->data browser->output list width->set to 2000....

  • I am having a problem printing emails from my Hotmail account when I am using Mozilla Firefox as my browser. When I click on the Print icon above the email and then proceed to print, the output on my Canon Pixma 830 printer is in extremely small type.

    I am not sure about all those installed plugins you have listed below.
    I know that I can always copy the text of my email and paste it into a Word file to be printed, but that is a hassle, and the output is not quite the same as when I print directly from the Web.

    Did you check what I would consider the first place to look:
    * http://kb.mozillazine.org/Problematic_extensions
    If the site is still down (at least 12 hours) when you read this try [http://webcache.googleusercontent.com/search?q=cache:http%3A//kb.mozillazine.org/Problematic_extensions Google's cache]
    Link or url would make it easier to see which page you tried rather than "your online solution for ...".
    * http://kb.mozillazine.org/Firefox_hangs ([http://webcache.googleusercontent.com/search?q=cache:http%3A//kb.mozillazine.org/Firefox_hangs cached version])
    * http://kb.mozillazine.org/Firefox_crashes ([http://webcache.googleusercontent.com/search?q=cache:http%3A//kb.mozillazine.org/Firefox_crashes cached version])
    * [https://support.mozilla.com/kb/Firefox%20hangs#os=mac&amp;browser=fx4 Firefox hangs | Troubleshooting | Firefox Help]

  • Problem in printing the output of a script.

    dear friends,
    I have a script program which is running fine and the it has generated the desired output in one page on the screen. But when i am transfering the output to the printer the same output is splitting into 3 pages and special character is printing in begining and ending of every line. In the first page It is printing the special character, in the second it is printing the first line output and in the third page rest of the output.
    In my script i have only the main window. i want the script output to be printed only in one page on the printer . Please help me with your suggestions.

    Sravan,
    Check ur printer as sometimes it so happens that the printers act up and spoil output...

  • Problem with the Output Type and Transaction ME9F

    Hi,
          I have an Output Type (xyz) and Program (abc).
          If for ME21N i give the output type ( xyz ) the n am able to get the Spool and 
          Printout.
          If for ME9F i give the output type ( pqr) then am able to get the Spool and 
          Printout.
          Problem is :---
          when am using O/P Type ( xyz ) for ME9F then am abel to process but am
          not able to get the spool and not even printout.
          I want to know where it can be wrong.
          It's a high priority object.
    Kindly help me out.
    Thanks,
    Zia.

    hi Zakir,
    1.check the output type under
    apllications  'EF' IN transaction  NACE.
    2.select that ef and press the push button output types .
    3. now check ur output for is present here or not ..
    just click the position button and give ur output type ..
    4. when u find ur output type .. select that o/p type and click processing routined on the left side where u will see ..
    when u do this
    u ll see the details like
    output type . the output type  "
    application . 'EF'
    and the mode of medium .
    1. print out
    2. fax .
    6. edi etc.
    this is the way to check what are the mediums present for the output type ..
    check whether u r <b>entries (xyz) and (pqr) are having medium 1.</b> 
    if its missing  then assign it ..
    regards,
    VIjay

  • Problem displaying the output in the same view

    hi Gurus,
    I have developed an web dynrpo application and have three views, in the first view I am having an input field from which I am calling a BAPI by giving that input field value as input to the BAPI.
    Now is it possible to display the output also retrived from the BAPI on the same view.
    Thanks and regards
    kris

    hi LM,
    Thanks for your fast response.
    I think I was not clear in explaining my problem.
    I have a view in which I have an input field which is the input to the BAPI, now on entering the value in the input field I have a submit button, on clicking the BAPI should be executed and also the the output should be displayed on the same view.
    Now regarding the mapping both the input and output are in the same context, would that a problem.
    And also after getting the output from the BAPI I have to do some validations based on the output from the BAPI and get some message printed on the view.
    Please help me in this issue.
    Thanks and regards
    kris

  • Regarding the printing the output as many no of times

    hi ,
    the issue is, i need to print the report output as many number of times as i want
    based on the value of input parameter. how can i do it?
    we are using format type as xml so no layout model.
    can anybody plz give the solution.
    regards
    arun.b

    There is probably a better way to do this, but one option is a cartesian product to get the query results to repeat. So join to a table (any table with lots of rows) like the following:
    SELECT youcols
    FROM yourtable,
         (SELECT 1 FROM big_table WHERE rownum <= :numrows)
    WHERE yourwhereclause

  • Micro Zen | problem with the output "ho

    Hello.
    For a few weeks now the contact in the output "hole" get worse and worse. When i plug in my earphones and only touch and bend the plug a little bit in direction to the screen, the sounds gets all numb,quiet and sometimes i hear nothing. It turned that worse that i can't have the Zen in my pockets anymore, cuz the cable bends and so the sounds goes all quiet...
    I think it's a warranty subject, what do I have to do to send it in? I had a problem last july with it already and sent it in, but forgot the procedure it goes through
    Oh and I also handed it in to my local shop where i bought the Zen in 2005 because of a hardware issue and they got me a new one from creative (so they handled the whole RMA procedure).
    So what am I gonna do now? I bought the Zen in july 2005 and Creative already knows that because of the first RMA ^_^

    Before you do anything. Which headphones are you using? Are you using a case?
    My case fits around the hole perfectly so if the plug of the headphones is to thick like my Sony MDR-V50 (http://images.amazon.com/images/P/B000092YPR.0.LZZZZZZZ.jpg) it will play.. but if I move the wire around just a bit only the left side of the headphones will work. So I have to use the earbuds that came with my MicroPhoto.. a shame to cause headphones sound so much nicer then earbuds.. oh well. Try a different pair of headphones/earbuds.

  • Printing: The outputs print on a printer other than that specified on the u

    We are using activity profile on the shipment to trigger outputs at different statuses set on the shipment document. In order to have the output trigger based on activity profile we need to have the timing for these output types set to “3”. Now the outputs set in the activity profiles are proposed on the sales document the first time the document is saved by the user. The communication details for the outputs proposed have the details from the user data set in the user master (SU01) for the person who saved the sales document as the print parameters for the output is “S” (user parameters).
    The issue is we want the system to print outputs proposed on the sales document to different printers.  E.g. The bill of lading output on the shipment document is required by the shipment planner to provide the same to the truck drivers. However the documents like pick list are required by the loaders loading the packages in the warehouse. Hence the documents need to be printed in different printers. How do we achieve this when the outputs proposed at the time the sales document is saved have the print parameters form the user data of the user who created the document?

    Hello,
    Have a look here:
    http://help.sap.com/saphelp_erp2004/helpdata/EN/7e/36e4c4023411d399b70000e83dd9fc/frameset.htm

  • Adhoc Query- problem with the output file format

    Hi Gurus,
    I have a problem in exporting the output of an adhoc query to Excel format.
    The menu option I chose to export the report data into Excel is List>Export>Spreadsheet.
    However,I think I've just pressed the wrong option to export my report and now I can't seem to change it from a HTML file option.
    Can anybody help me correct this output setting.
    Points assured for apt help...

    Hi Sushil,
    There are two ways to save the output in the excel format.
    As you have mentioned, you can use
    List -> Export-> Spreadsheet.
    Then select table. Now the output will open in a spreadsheet.
    The other way is
    List -> Export-> Local File
    Here you need to select the option spreadsheet. Then mention the path where you want the file to be stored. Also mention the format as .xls
    Hope this helps
    Regards,
    Brinda

Maybe you are looking for

  • Oracle 11g Installation issue

    Hi: I am trying to install 11g on linux from VNC viewer and got error " [INS-32012] Unable to create directory" at "Typical Installation step. I have for example given Database file location as /u01/app and this directory is created on linux and it i

  • Media Streaming shows no entries

    Media Server is set up, shared folders for Video, Music and Pictures are configured and the Server seems to run correctly so far, BUT it offers no files for streaming. The Media Server is up and running, the underlying services are OK, no errors show

  • Aftereffects, Photoshop or other grafic Sequence imports?

    Hey People, Two questions to people really using FCPX. I am still doubting to buy FCPX because of this. I need to buy the full set of Adobe Production Suite anyway for Photoshop, Illustrator and Aftereffects. Yes, I will have the by then almost free

  • Free Upgrade To Final Cut Studio 2?

    Hello, Was wondering something. I bought Final Cut Studio just over a month ago. Since Apple have just come out with Final Cut Studio 2 is this just a case of me being unlucky or is there a facility where I can get the upgrade for free, since I have

  • Objects of application scope and clustering.

              I understand that weblogic 6.1 replicates session data to a secondary server in a           cluster. This replication should include objects declared with <jsp:useBean ...           scope="session"/> as well as objects that are explicitly m