Results 1 to 2 of 2
  1. #1
    pittypatsfan is offline Member
    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Default Help with a java program, I'm just learning...

    I have a problem, I'm trying to write a program using loop and conditional statements that will calculate the overall grade of a student and produce the letter grade as well. I need to give 5 assignment grades, which it will take the highest 4 and get an average which is worth 25% of the grade. A score for the first exam which is worth 15% of the grade, a second exam grade also worth 15%, a lab grade worth 25% and a final exam grade worth 20%.
    >=90 is A, >=80 but < 90 is B, >=70 but < 80 is C, >= 60 but < 70 D, and < 60 is F. So at the end it will say "The weighted average is" and produce a letter grade "You will receive a B" for example. Also it needs to have "Do you want to calculate for another student? Please type true or face. if True enter grades again, if false "bye" . Hopefully that makes sense, I am having problems and I'm not sure where to go... This is what I have so far........

    import java.util.Scanner;

    public class CalculateGrades {
    public static void main(String[] args) {

    int f = (f > 0 && f < 59);
    int d = (d >= 60 && d < 70);
    int c = (c >= 70 && c < 80);
    int b = (b >= 80 && b < 90);
    int a = (a >= 90);

    Scanner sc = new Scanner(System.in);

    //Ask user to enter 5 assignment grades
    System.out.println("Please enter your 5 assignment grades");


    if (aGrade < lowest) {
    lowest = aGrade;
    }
    total = total + aGrade;
    while ();
    assignmentAverage = (total-lowest) / 4;

    //Ask the user to enter 2 exam grades
    System.out.println("Please enter your 2 exam grades");

    //Ask the user to enter their lab grade
    System.out.println("Please enter your lab grade");

    //Ask the user to enter grade for final
    System.out.println("Please enter your final exam grade");

    System.out.println("Do you want to calculate for another student? Please type true or false");

    System.out.println("Bye, bye!");


    }

    }

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Help with a java program, I'm just learning...

    Java Code:
    int f = (f > 0 && f < 59);
    int d = (d >= 60 && d < 70);
    int c = (c >= 70 && c < 80);
    int b = (b >= 80 && b < 90);
    int a = (a >= 90);
    What exactly are you trying to do? The result of all the right hand side statements are booleans and yet you are trying to assign them to int variables.
    Java Code:
    if (aGrade < lowest) {
    lowest = aGrade;
    }
    total = total + aGrade;
    What is aGrade?
    What is lowest?
    What is total?

    Before you start bashing away at a keyboard you need a clear idea in your head how the program should execute. This usually requires writing down the step-by-step instructions on paper. Only when it makes perfect sense should you start converting it to code.

Similar Threads

  1. Java Learning
    By JTUS in forum New To Java
    Replies: 2
    Last Post: 12-12-2011, 01:30 AM
  2. Replies: 12
    Last Post: 06-14-2011, 05:55 PM
  3. need help learning methods and fixing my basic program
    By shazakala in forum New To Java
    Replies: 4
    Last Post: 03-21-2011, 10:12 AM
  4. Learning Java
    By Derkins in forum New To Java
    Replies: 3
    Last Post: 04-09-2009, 03:46 AM
  5. [SOLVED] Need a program for learning purposes.
    By Zebra in forum New To Java
    Replies: 19
    Last Post: 05-03-2008, 04:46 AM

Posting Permissions

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