How to Add Numbers in an Array

I understand that you would use a for loop, but I don't know what would come after:
for(int b=0; b<array.length; b++){ Please help!!!
I have tried this on my own, but nothing is working!!!
Thanks in advance
Edited by: Sevan on Oct 12, 2008 2:12 PM

I finally figured it out!!!
Here is what I did:
import java.util.*;
public class Grades
    public static final void main(String[] args)
        Scanner scanner = new Scanner(System.in);
        System.out.println("Insert Number of Grades to Average");
        int x = scanner.nextInt();
        int[ ] array = new int[x];
        System.out.println("Insert Grades Below");
        for(int i=0; i<x; i++){
        int r = i+1;
        System.out.println("Grade Number " + r);
        array=scanner.nextInt();
if(array[i]<=100 && array[i]>=0){
continue;
else{
System.out.println("Error: Only Enter Grades Between 0 and 100");
return;
int h=0;
for(int b = 0; b < x; b++){
h = h+array;
double y = h/x;
System.out.println("The Student's Average is " + y);
The solution starts 5 lines from the bottom.
However,
I feel like there is an easier solution to this problem
If there is, please let me know!!!
Thank you

Similar Messages

  • How to add a 2D result array to the result database?

    I am using Teststand 3.5 and I am about to create a Labview VI that will measure the gain response of a receiver. This VI will output it as an 2D-Array and I would like to save it to my access result database, to be able to use that data for displaying a graph in my excel report.
    I am new to teststand and I already know how to add a 2D-array to a report but don't really know how to add this information to the database. I read the provided manuals and searched the forums but didn't find anything that was really helpful. AFAIK I can add numerics and strings to the database just by adding a string value or numeric limit test but when it comes to arrays (especially 2D), I have no idea how to do that. I only know (or guess) that I have to add a new  table to my database, edit the schema and the Database.seq.
    I appreciate any help!
    Stephan

    Stephan,
    Sometimes forum posts make you research a particular functionality of TestStand and lead you to discover how powerfull TestStand can be.  This is one of these cases.  I thought that in order to save 2D arrays in TestStand we would have to customize many different aspects of the application only to learn that the functionality is fully implemented already!
    First, you will have to create a new step type that contains a 2D array in the Step.Result properties.
    Second, in order to save a 2D array into a database, use the Binary Column Type in your table.  To do this, create a new table with the following properties:
    Type: Recordset
    Command text: "SELECT * from [Table Name]"
    Apply to: Step Result
    Types to Log: [Step type with which you are acquiring your 2D array]
    Lock Type: Optimistic
    The rest of the properties can be left with their default values.  Once you have your table, add an ID column as your primary key, and a second column that will contain the 2D array.  This column should have the following properties:
    Type: Binary
    Size: 1.5 times the size of your array in bytes
    Expected Properties: Logging.StepResult.[Property Containing the Array]
    Expression: Logging.StepResult.[Property Containing the Array]
    The rest of the properties can be left with their default values.  In order to see the values stored in the database, open the Database Viewer to the particular table and right click on the field which will show a value of "Binary Data".  Right click on the value and select Evaluate Data.  The View Binary Data window will let you see all the values stored in the array.
    Regards,
    Santiago D

  • How to add all element of array?

    1-D array has N number of element .i want to sum all the element ,and the result is a number.
    can you give me some example?
    thanks.

    Just use the "Add Array Elements"-function located in the Numeric palette.
    Message Edited by becktho on 02-21-2006 12:58 PM
    Using LV8.0
    Don't be afraid to rate a good answer...
    Attachments:
    AddArrayElements.PNG ‏14 KB

  • How to add numbers in XML?567- 5+6+7=18?

    I have a requirement in check printing to print the check no at the bottom of the check.
    1.     Compute sum of all the digits in the check number and divide it by 9.
    E.g.:
    1.     0+0+7+0+0+5+7+9 = 28 (SUM)
    2.     28 / 9 = 3 (with remainder 1)
    3.2.     Compute the difference between 9 and the remainder in step 2. This number is the check digit (Modulus 9).
    E.g.:
    1.     9 – 1 = 8
    2.     8 is the check digit.
    If the remainder in Step2=0, then the check digit is 9
    So I will display 007005798
    In XML or XSL , How can I do this?
    Question: Is there any built in SQL function available to compute the sum of individuals of a number?For eg 567-> 5+6+7=18
    If I am ending up wrinting a function for the above how can I call that in RTF?
    thanks
    prasanna

    Srini
    Can you please help me out..The xml formula works for hardcoded values but not for the actual tag values.
    1) I am not finding space to copy the following into the form field:\
    You gave:
    <?9-((substring(555555555,1,1)+ substring (555555555,2,1) + substring (555555555,3,1) + substring (555555555,4,1) + substring (555555555,5,1) + substring (555555555,6,1) + substring (555555555,7,1) + substring (555555555,8,1) + substring (555555555,9,1)) mod 9)?>
    I remodified for my situation:
    <?9-((substring(../PaymentNumber/CheckNumber,1,1)+ substring (../PaymentNumber/CheckNumber,2,1) +
    substring (../PaymentNumber/CheckNumber,3,1) + substring (../PaymentNumber/CheckNumber,4,1) +
    substring (../PaymentNumber/CheckNumber,5,1) + substring (../PaymentNumber/CheckNumber,6,1) +
    substring (../PaymentNumber/CheckNumber,7,1) + substring (../PaymentNumber/CheckNumber,8,1) +
    substring (../PaymentNumber/CheckNumber,9,1)) mod 9)?>
    But the above dont fit into the form field.How to take care of this?
    thanks
    prasanna

  • I am using numbers in the new iWork. Just bought it 10 days back. I am not able to figure out how to add serial umbers from 1 to 100( for example) also i need to freeze the top header like in windows so that we can browse down without the heading going of

    i am using numbers in the new iWork. Just bought it 10 days back. I am not able to figure out how to add serial umbers from 1 to 100( for example) also i need to freeze the top header like in windows so that we can browse down without the heading going off. Can some one help?

    Hi Jay,
    Be aware that "Freeze Header Rows" and "Freeze Header Columns" apply only to rows and columns that are Header rows or Header columns. You can have up to five Header rows, Five Header Columns (and five Footer rows) on a Numbers Table.
    "Header rows" is a special designation. Besides being able to be frozen, Header and Footer rows are not included in formulas referencing whole columns, making it possible to place formulas such as =SUM(B) at the top (or bottom) of column B without causing a self-reference error, These designated rows are also not included in sorts of the rows in a table.
    Regards,
    Barry

  • How to add two different page numbers in a single page

    How to add two different page numbers in a single page? One is for page number of the whole article, the other one is for page number for each chapter in the article.

    It's quite complicated, see
    Two Page Numbering Schemes in the Same Document.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • ? how to add page numbers in pages 5.2, starting with 2.  Pages '09 had an option to not show folio on page one.  Also any how to do left and right folios for a Tabloid?  Many trhanks

    ? how to add page numbers in pages 5.2, starting with page 2.  Pages '09 had an option to not show folio on page one.  Also any idea how to do left and right folios for a Tabloid?  Many thanks  . . .

    Hello jacquemac,
    Your first question:
    There might be a better way of achieving what you wish to do, but following these steps could help you out.
    You might want to blend in Thumbnails and Invisibles either with (cmd+shift+i and cmd+alt+p) or over the View section in the Menubar.
    1. go for Documents (right end of the Toolbar) -> Section
    2. place your cursor at the very top of your second page and click "Create new Section->Starting with this page" in the side bar on your right.
    (what you are actually doing next is setting the pagenumbers for each section you created. You can see your sections in the Thumbnail view.)
    3. click on your first page (the first and only page of your first section) and mark the checkbox "Hide on first page of section"
    4. click on your second page (the first page of your second section) and  "Insert page number" -> start at 1
    Your second question:
    Im not quite sure i understand what exactly you want to do here. One page, two columns, each column with another page number? As far as i know this is not possible.
    greetings jl

  • How to add page numbers in Numbers?

    How to add page numbers in Numbers?
    Is there a simple way like in Excel? Thanks.

    In Numbers '09, use Insert > Page Number
    Place the page number in a page header, and it will appear on each age when in Print View and when the file is prnted.
    May have changed in Numbers 3 (current version).
    Regards,
    Barry

  • Hello, I would like to know how to add or delete single cell in numbers.

    Hello, I would like to know how to add or delete single cell in numbers.

    If by delete you really mean clear the contents of a cell, then just click once on the cell and hit the 'delete' button.
    Before:
    After hitting delete button:
    In some circumstances you can actually delete one cell.
    For example here, I make this choice:
    Resulting in this:
    So it's not strictly true that Numbers does not delete one cell, ever.  It can if you have a one-column table. 
    So never say never or not ever! Enough pedantry for today!
    SG

  • Using the value "Image/*" for the accept attribute of the HTML input Element, how can I add .pdf to the array of preconfigured file types (.jpe, .jpg, .jpeg, .?

    On a form, using the value "image/*" for the accept attribute of the HTML input Element, how can I add .pdf to the array of pre-configured file types (.jpe, .jpg, .jpeg, .gif, .png, .bmp, .ico, .svg, .svgz, .tif, .tiff, .ai, .drw, .pct, .psp, .xcf, .psd, .raw)?
    Say I wanted to add .gif, .jfif or .ico. I find this array limited, how can I add types to image?
    <input type="file" name="file" accept="image/*" id="file" />
    mimeTypes.rdf does not seem to allow this.

    ''mimeTypes.rdf'' has nothing to do with web development. It's a file that stores your file handling preferences (e.g. if you want ZIP files automatically saved or opened).
    You can't change the file types of the pre-defined content specifiers (audio/*, video/*, image/*), but you can specify additional MIME types. To add PDF to your above example,
    <pre><nowiki><input type="file" name="file" accept="image/*,application/pdf" id="file" /></nowiki></pre>
    For details, see
    * [https://developer.mozilla.org/En/HTML/Element/Input developer.mozilla.org/En/HTML/Element/Input]

  • Object array - how to add items?

    Hello!
    I have little problem, how to add item to array, to get something like this:
    Object[][] someObject = {
    {"1", "2"},
    {"4","5"}
    };From this:
    Object[][] someObject = {
    {"1", "2"}
    };? Thanks in advance!

    Once you allocate an array like that, you can't
    resize it.
    Object[][] someObject = {
    {"1", "2"}
    };creates an array with size [1][2]. You can't makeit
    any larger. You can create a new Object[][]
    with the new size, copy the elements into the new
    array, then add your new objects in the newposition.
    or even better use arraylistExcept that he's using this for a JTable, so the best he could do is a Vector. Yuck. :)

  • How to add an element to an array, then be able to remove it specifically

    So i have a list of numbers. The user is able to then add numbers to that list. I have a button which allows the user to remove any number of their choice by typing that number in a textbox. For some reason the numbers that the user add to the list will not dissapear when chosen whereas the original numbers go away no problem.
    The name of the array itself is mesEntiers and the name of the texbox is : IntegersIn_txt
    Here is the code :
    function supprimer(event:MouseEvent):void
      var indiceChiffre:int;
      indiceChiffre =(mesEntiers.indexOf(IntegersIn_txt.text));
      // La méthode indexOf renvoie l'indice d'un élément ou -1 si non trouvé.
      trace("testBtn")
      if (indiceChiffre != -1)
      for (var i=indiceChiffre; i <mesEntiers.length; i++)
      mesEntiers[i] = mesEntiers[i+1];
      trace("test")
      mesEntiers.pop();
      } // Fin fonction supprimer.

    Two things I can think of (I ran a small test)...
    1) Make sure your textfield is a single line, not multiline...  multilines end up with extra stuff in them that you can't see.
    2) Convert the text into a number unless the array is holding strings...  indiceChiffre =(mesEntiers.indexOf(Number(IntegersIn_txt.text)));

  • How to add byte[] array based Image to the SQL Server without using parameter

    how to add byte[] array based Image to the SQL Server without using parameter.I have a column in table with the type image in sql and i want to add image array to the sql image column like below:
    I want to add image (RESIM) to the procedur like shown above but sql accepts byte[] RESIMI like System.Drowing. I whant that  sql accepts byte [] array like sql  image type
    not using cmd.ParametersAdd() method
    here is Isle() method content

    SQL Server binary constants use a hexadecimal format:
    https://msdn.microsoft.com/en-us/library/ms179899.aspx
    You'll have to build that string from a byte array yourself:
    byte[] bytes = ...
    StringBuilder builder = new StringBuilder("0x", 2 + bytes.Length * 2);
    foreach (var b in bytes)
    builder.Append(b.ToString("X2"));
    string binhex = builder.ToString();
    That said, what you're trying to do - not using parameters - is the wrong thing to do. Not only it is insecure due to the risk of SQL injection but in the case of binary data is also inefficient since these hex strings are larger than the original byte[]
    data.

  • How do I add numbers to contact groups I've created

    Ive created a list of sub-groups for my fairly extensive contact list, but I can't figure out how to add contacts to these subgroups without having to re-enter the contact info as a "new contact".   Is it possible to select from my "All Contacts" list those numbers I want included in a particular subgroup?

    Email the contact to yourself (share contact).
    In the contacts app, make sure you are in the proper group.
    Import the contact
    Delete the contact in the old group.
    Or:
    http://itunes.apple.com/us/app/speed-names-contacts-groups/id285124918?mt=8

  • Adobe Reader - how to add page numbers with the free version?

    Hey guys,
    Imagine I've got a PDF file and I want to create a new one by selecting some pages out of it. I know this is simply possible by using the PDFcreator but I want to add page numbers. As far as I know this is not possible with the free version of Adobe unless I would add the page number on every single page by using a text box. I want to make different catalogs from the PDF so the page numbers are really necessary. Have you got any idea how to solve that issue? You know that's pretty much the only thing I need to add which means it's not worth buying the Pro version. Unfortunately I only got the PDF and I can't work on it e.g. with MS word before I export it. Do you know if there is a way to add page numbers with a free version? There might be an additional free software which allows that?
    Thanks for your support! 

    Thanks for your quick replies.
    I know how to add text page by page. But obviously it's hard to place the numbers on the very same position, is it?

Maybe you are looking for

  • Open and print a PDF from web

    I created an application to open a PDF and print it directly on the default printer. This application works if the file is a Windows' network address (example: \\192.168.0.4). But if I put an internet address (URL), the Acrobat Reader presents the fo

  • Cisco ASA 5510 - Cisco Client Can Connect To VPN But Can't Ping!

    Hi, I have an ASA 5510 with the configuration below. I have configure the ASA as remote access vpn server with cisco vpn client, my problem now is I can connect but I can't ping. Config ciscoasa# sh run : Saved ASA Version 8.0(3) hostname ciscoasa en

  • How to output a recordset

    I copy this store procedure from the other thread create or replace procedure ref_cursor(rc out sys_refcursor) is begin           open rc for select * from customers ; end ; and I use this function to call the store procedure in an ASP page      Func

  • Jdeveloper set up for MSCA(Mobile supply chain application) custom page

    Hi Everyone, Can anyone provide me with the jdeveloper setup instructions to write class files for MSCA Application. I was trying to redo the helloworld tutorial from anil passi.com(http://oracle.anilpassi.com/hello-world-mobile-supply-chain-applicat

  • Updated to 10.9.5 and trouble loading saved game FM2014

    Hi, playing Football Manager 2014 was never a problem on my Macbook Air.  Yesterday I updated the system to 10.9.5.  Today I wanted to play the game again and there seems to be a problem with the free memory. Any idea how to solve this problem? I'm a