Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2011
    Rep Power

    Default Help with Java code

    I'm working on a program, and I'm stuck. I need to calculate the sum, average, largest and smallest elements of an array. I am supposed to use a for loop to test if the number is between 90 and 100, If number is in this range, I should add 1 to the Talley of grade A. This is to be done for grades B,C,D. My question is how do I display a list of how many students had A's, B's etc.

    Any help would be appreciated

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Richmond, Virginia
    Blog Entries
    Rep Power


    It tells you what to do in the assignment. How you want to do it is up to you. For example you can have an it variable for each letter grade. What have you tried so far? Post some code(wrap it in code tags)

  3. #3
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Atlanta, Georgia, US
    Rep Power


    You would have 5 variables for each grade, then add one to the appropriate variable for the respective grade.

    Java Code:
    int gradeA = 0, gradeB = 0, gradeC = 0, gradeD = 0, gradeE = 0;
    for(int grade : grades) {
        if(grade >= 90) gradeA++;
        else if(grade >= 80) gradeB++;
        else if(grade >= 74) gradeC++;
        else if(grade >= 70) gradeD++;
        else gradeF++;

Similar Threads

  1. Translate code into Java code
    By Radu in forum New To Java
    Replies: 5
    Last Post: 04-12-2011, 10:27 AM
  2. Replies: 0
    Last Post: 02-21-2011, 12:50 PM
  3. Convert java code to midlet code
    By coldvoice05 in forum New To Java
    Replies: 1
    Last Post: 08-12-2009, 12:14 PM
  4. Convert java code to midlet code
    By coldvoice05 in forum Advanced Java
    Replies: 1
    Last Post: 08-09-2009, 02:21 PM
  5. Java Code
    By g.ganiraju in forum New To Java
    Replies: 2
    Last Post: 10-20-2008, 03:18 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