Results 1 to 2 of 2

Thread: GradingProgram

  1. #1
    pearcewl is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Question GradingProgram

    I am very new to Java, and have HW due soon, and was just wondering if someone could shed some light on to why the second portion of my code (section dealing with the max/min of the data) is not functional. I simply do not understand what is holding me up, and have been stuck for hours, and it is due asap, any help would be appreciated!

    Thanks.

    P.S.

    import java.util.Scanner;

    public class GradingProgram
    {
    public static void main(String[] args)
    {
    double sum;
    int numberOfAssignments;
    double next;
    Scanner keyboard = new Scanner(System.in);
    String answer;
    do
    {
    System.out.println();
    System.out.println("Enter the scores you want to average, the high, and low");
    System.out.println("Enter a negative number after");
    sum = 0;
    numberOfAssignments = 0;
    next = keyboard.nextDouble();
    while (next >= 0)
    {
    sum = sum + next;
    numberOfAssignments++;
    next = keyboard.nextDouble();
    }
    if (numberOfAssignments > 0)
    System.out.println("The average is " + (sum / numberOfAssignments));
    else
    System.out.println("No scores to average, YA JACKASS.");
    answer = keyboard.next();
    }while (answer.equalsIgnoreCase ("<0"));


    do
    {
    Scanner keyboard2 = new Scanner(System.in);
    double max = keyboard2.nextDouble();
    double min = max; // The max and min so far are the first score.
    next = keyboard2.nextDouble();
    while (next >=0)
    {
    if (next > max)
    max = next;
    else if (next < min)
    min = next;
    next = keyboard2.nextDouble();
    }
    System.out.println("The highest score is " + max);
    System.out.println("The lowest score is" + min);
    } while (answer.equalsIgnoreCase("<0"));
    }
    }

  2. #2
    pearcewl is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Exclamation Uhhh

    26 views, no responses I thought it would be a common error, could someone please respond, or give me a hint?!?! Due tomorrow!:mad:

Posting Permissions

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