Results 1 to 2 of 2
  1. #1
    masterasia is offline Member
    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    Default Keeping track of running total help

    these are the questions given within the homework:

    Write a java program for tasks specified below,
    1. First prompt the user to enter the number of students you have in your group
    2. Declare three parallel arrays of strStudentName[], dblStudentMark[], strStudentGrade[] &
    intStudentSD[]
    3. In a For loop, ask the user to enter the student name and midterm mark, store the
    information into the above arrays (strStudentName[] & dblStudentMark[]), and report each
    entry using println statements
    4. In the loop keep track of a running total

    And this is what I have so far:


    public class A4Q2 {

    public static void main (String[] args){

    String group = javax.swing.JOptionPane.showInputDialog("How many students do we have in our group?");
    int amountgroup = Integer.parseInt(group);

    String[] strStudentName = new String[amountgroup];
    double[] dblStudentMark = new double[amountgroup];
    String[] strStudentGrade = new String[amountgroup];
    int[] intStudentSD = new int[amountgroup];

    String n;
    String m;

    for (int i=0;i<amountgroup;i++)
    {
    n=javax.swing.JOptionPane.showInputDialog("Enter the student name");
    strStudentName[i]=n;

    int counter = 0;
    int total = 0;

    while (counter <= n)
    {
    total += counter;
    counter++;
    }

    System.out.println(counter++);

    m=javax.swing.JOptionPane.showInputDialog("Enter the midterm mark");
    dblStudentMark[i]=Integer.parseInt(m);

    while (counter <= m)
    {
    total += counter;
    counter++;
    }

    System.out.println(counter++);

    System.out.println(strStudentName[i]);
    System.out.println(dblStudentMark[i]);
    }
    }
    }

    I am currently stuck on #4 as my counter loop keeps displaying this message "operator <= cannot be applied to int,java.lang.String" I dont understand what my error is. :confused:

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Use code tags to post codes -- [code]CODE[/code] will display as
    Java Code:
    CODE
    db

Similar Threads

  1. Running total little help
    By silverspoon34 in forum Forum Lobby
    Replies: 9
    Last Post: 02-27-2011, 09:19 PM
  2. Keeping one window above another
    By porchrat in forum AWT / Swing
    Replies: 3
    Last Post: 01-27-2011, 08:11 AM
  3. Running Total by Key Group in HashMap
    By KevMull in forum New To Java
    Replies: 3
    Last Post: 11-16-2009, 03:44 PM
  4. Keeping track of Copies + Comparisons in Sort Methods
    By VinceGuad in forum New To Java
    Replies: 0
    Last Post: 03-12-2009, 04:07 AM
  5. Track download
    By nilesh.malode in forum Advanced Java
    Replies: 1
    Last Post: 07-13-2007, 09:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •