Good day to all programmers there!!!!,
please help me to my assignment, I need it tommorow!
I want a program that
1.input the name of student,
2.input his/her grades
3. display its grade rate
4. display if it is perfect, pased or failed

:)

Dani AI

Generated

The request: read a student name, collect grades, compute a "grade rate" (average) and print whether the result is Perfect, Passed or Failed. Several replies (for example and ) rightly encouraged attempting the code first; noted that console input is required. Below is a compact, beginner-friendly pattern that shows one safe way to handle input, compute an average, and classify results. The pass/perfect thresholds are explicit constants and can be changed to match course rules.

import java.util.Scanner;

public class GradeCalculator {
    private static final double PASS_THRESHOLD = 60.0;
    private static final double PERFECT_THRESHOLD = 100.0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Student name: ");
        String name = sc.nextLine().trim();

        int count = readInt(sc, "How many grades? ");
        double sum = 0;
        for (int i = 1; i <= count; i++) {
            double g = readDouble(sc, "Grade #" + i + ": ");
            while (g < 0 || g > 100) {
                System.out.println("Enter a grade between 0 and 100.");
                g = readDouble(sc, "Grade #" + i + ": ");
            }
            sum += g;
        }

        double avg = count == 0 ? 0 : sum / count;
        System.out.printf("%s - Average: %.2f%%\n", name, avg);

        if (Math.abs(avg - PERFECT_THRESHOLD) < 1e-9) {
            System.out.println("Result: Perfect");
        } else if (avg >= PASS_THRESHOLD) {
            System.out.println("Result: Passed");
        } else {
            System.out.println("Result: Failed");
        }
        sc.close();
    }

    private static int readInt(Scanner sc, String prompt) {
        while (true) {
            System.out.print(prompt);
            try { return Integer.parseInt(sc.nextLine().trim()); }
            catch (NumberFormatException e) { System.out.println("Not an integer; try again."); }
        }
    }

    private static double readDouble(Scanner sc, String prompt) {
        while (true) {
            System.out.print(prompt);
            try { return Double.parseDouble(sc.nextLine().trim()); }
            catch (NumberFormatException e) { System.out.println("Not a number; try again."); }
        }
    }
}

Notes: adjust PASS_THRESHOLD to match grading rules (some courses use 50, 60, or a weighted scale). Validate ranges and handle zero-grade lists explicitly. The approach above is straightforward for beginners and follows the input-validation advice already mentioned in the thread.

Recommended Answers

All 6 Replies

brightstar, I don't think you'll get any help if you just want somebody to do your homework for you. Try to write the program as best you can and then post if you have any questions....

public class YouFail {
    public static void main(String[] args) {
       System.out.println("brightstar fails, is didn't turn in its homework so has no grades");
    }
}

There you go.

this is very simple,, at least do some coding.. fails!!

since you do not need it before tomorrow, it's quite an easy task.
couldn't take more than 1 hour from someone who has only been teached java for a month
(thinking about not the brightest student, and sure am stretching the time)

don't be afraid to start coding, and to post your code here, especially if it doesn't work.
it'll help you much more understanding if you programmed it yourself, and it might convince some people here that (one day) you might be serious about programming and might deserve some help

public class Homework {
    public static void main(String[] args) {
       System.out.println("grade is" + grade);
    }
}

Simple

Hint: try to get the name of the student and his grades using the
BufferedReader input =new BufferedReader(new InputStreamReader(System.in));
int userInput = Integer.parseInt(input.readLine());

or else use the Command Line input

C:\java MyTestCalculate studentname grade1

then write method for calculating the grade or rank using if else conditions.

thats all to help. Try you will get

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.