Develop a java program for a grading system tha satisfies the ff requirement:\

  1. for passing an exam, a student must pass by a score of 30 or more and assessment of 20 or more to be issued a certificate
  2. if a student score a total grade of 49 for both exam and assessment, the student is condoned
  3. if a student satisfy both requirement 1 or 2 and paid their fees in full (thus $100), they're issued with certificate
  4. the student is deemed to have failed if he doesnt meet requirement 1 or 2
  5. however, the program must inform a student which requirement he passed or failed
  6. where a student fails both requirement, he is repeated

Recommended Answers

All 38 Replies

You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here.

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

this is as far as I can go....
a help with 5 and 6 will be Ok

  import java.util.Scanner;
    public class Grade 
    {
    public static void main(String[] args) 
        {

    int grade;
    int fees = 100;
    int examscore=0;
    int assessment=0;

    //take inputs from keyboard
    System.out.print(" Enter exam score " + examscore);
    System.out.print(" Enter class score " + assessment);
    Scanner keyboard = new Scanner(System.in);
    examscore = keyboard.nextLine();
    assessment = keyboard.nextLine();
    grade = examscore + assessment;
    fees = keyboard.nextline();

    System.out.println(grade);
        }

    if (( examscore > 30 )&& ( assessment > 20))
    {
    System.out.println(" Certificate allowed ");
    }
    else if (grade >=49)
    {
    System.out.println(" Please you're condoned");
    }
    else 
    {
    System.out.println(" Please you have failed ");
    }
    if (( grade >=49 ) && ( fees > 100 ))
    {
    System.out.println(" Please issue a certificate ");
    }
    else
    {
    System.out.println(" You are repeated ");
    }
    }

One step at a a time...
It's a bad idea to try to code the whole application before you start testing. Experienced programmers try to code in small pieces, compiling and testing as they go. That way it's easier to understand amd fix your errors.
You have enough code there to be able to compile, run, and test. Get that working before worrying about stages 5 asnd 6.

.I compiled this code without errors
but nothing shows again
it doesnt ask for my input

import java.util.Scanner;
    public class Grade 
    {
    public static void main(String[] args) 
        {

    int grade;
    int fees = 100;
    int examscore=0;
    int assessment=0;

    //take inputs from keyboard
    System.out.print(" Enter exam score " + examscore);
    System.out.print(" Enter class score " + assessment);
    Scanner keyboard = new Scanner(System.in);
    examscore = keyboard.nextInt();
    assessment = keyboard.nextInt();
    grade = examscore + assessment;
    fees = keyboard.nextInt();

    System.out.println(grade);


    if ( examscore > 30 &&  assessment > 20)
    {
    System.out.println(" Certificate allowed ");
    }
    else if (grade >=49)
    {
    System.out.println(" Please you're condoned");
    }
    else 
    {
    System.out.println(" Please you have failed ");
    }
    if ( grade >=49  &&  fees > 100 )
    {
    System.out.println(" Please issue a certificate ");
    }
    else
    {
    System.out.println(" You are repeated ");
    }
    }
    }

ok it runs but the display is
: Enter exam score 0 Enter class score 0

thats all

That's the output I would expect from line 13/14.
Did you enter 3 values for examscore, assessment, fees? Followed by a carriage return?

It's clearer for everybody if you prompt for one value at a time, eg (pseudo code)

print "what is the exam score" // NB print, not println
examscore = ...nextInt...
print "what is the assessment?
assessment = ...nextInt...
print "what are the fees> ?
fees = ...nextInt...
etc

good this one works now

import java.util.Scanner;
    public class Grade 
    {
    public static void main(String[] args) 
        {

    int grade;
    int fees;
    int examscore;
    int assessment;

    //take inputs from keyboard

    Scanner keyboard = new Scanner(System.in);
    System.out.print(" Enter exam score " + examscore);
    examscore = keyboard.nextInt();
    System.out.print(" Enter class score " + assessment);
    assessment = keyboard.nextInt();
    System.out.print(" Enter fees " + fees);
    fees = keyboard.nextInt();
    grade = examscore + assessment;
    System.out.println(" Total score" +grade);


    if ( examscore > 30 &&  assessment > 20)
    {
    System.out.println(" Certificate allowed ");
    }
    else if (grade >=49)
    {
    System.out.println(" Please you're condoned");
    }
    else 
    {
    System.out.println(" Please you have failed ");
    }
    if ( grade >=49  &&  fees > 100 )
    {
    System.out.println(" Please issue a certificate ");
    }
    else
    {
    System.out.println(" You are repeated ");
    }
    }
    }

am left with 5 and 6 and idea and does my program meet the logic of the question?

5: which requirements did he fail?
6. did he fail both?

One way would be to have a couple of booleans,one for each condition, showing whether that condition was met or not. You already have if tests for those conditions, so you have all the code you need to set the booleans.
You can then use them to control some print statements: eg (pseudo code)

if (metCondition1) print "you passed criterion 1"
else  print "you failed criterion 1"
   or 
if (didn't meet both) print "you must repeat"

thanks very much for the upgrade really appreciate it

looking forward to contribute my quota to daniweb

regards
stephen

hi guys,
I have a problem with this code
it gives the default case as the output no matter the score I enter.
help or guide will be appreciated

import java.util.Scanner;
    public class Grading 
{
    public static void main(String[] args) 
    {

    int score;

    Scanner keyboard = new Scanner(System.in);
    System.out.println(" Enter exam score " );
    score = keyboard.nextInt();

    switch (score)
        {
    case 1:
        System.out.println("A");
        break;
    case 2:
        System.out.println("B");
        break;
    case 3:
        System.out.println("C");
        break;
    case 4:
        System.out.println("D");
        break;
    case 5:
        System.out.println("F");
        break;
    default:
        System.out.println("INVALID");
        }
    }
}   

On line 12 try printing the value of score, maybe that will clarify what's happening

import java.util.Scanner;
    public class Grading 
{
    public static void main(String[] args) 
    {

    int score;

    Scanner keyboard = new Scanner(System.in);
    System.out.println(" Enter exam score " );
    score = keyboard.nextInt();
        System.out.println("score");
    switch (score)
        {
    case 1:
        System.out.println("A");
        break;
    case 2:
        System.out.println("B");
        break;
    case 3:
        System.out.println("C");
        break;
    case 4:
        System.out.println("D");
        break;
    case 5:
        System.out.println("F");
        break;
    default:
        System.out.println("INVALID");
        }
    }
}   

still prints INVALID

NO! I meant print the value of the variable score so you can confirm that it is 1, 2, 3, 4, or 5

sort of confused please

System.out.println("score");
this prints the String "score", James asked to do:
System.out.println("score: " + score);
so you could verify the actual value

the problem is the program fails to switch inbetween the Cases. it just prints the default case "INVALID"

Yes you already said that. Repeating it is just a waste of time.
Printing "INVALID" implies that the value you are switching on is not 1, 2, 3, 4, or 5.
Maybe when you execute the score = keyboard.nextInt(); you are not getting the value you expect.
That's why I asked you to print the value of the score variable.

I did that and the score prints but the grade doesnt switch

and what does that score print?
can you be specific about that?

silly me didnt specify things clearly,
this is what the program should do

= 70 print A
60 - 69 print B
50 - 59 print C
40 - 49 print D
< 40 print F

I think gh.fuz is just having fun with us. Anyway, joke over as far as I'm concerned. Bye. J.

hey not funny please I need the help

help me

OK, one last chance. You have been asked repeatedly what value for score is printed when you run the program. You have ignored those requests. What does it print?

and where do you get 70, 69-60, ...
in your code, there's 1,2,3,4,5 and INVALID
if you have 70 as score ... well duh. it'll print invalid.
if you want ranges, either you use waterfall in your case clauses, or you use if-else statements.

it prints INVALID

gh.fuz. first read James' post. answer his question.
then read mine: there, I explain WHY it prints invalid.

From the very first post it was clear that score was a number up to at least 49, so I suspected the value being used was > 5.
But since gh.fuz has continued to deliberately ignore or deflect our requests to reveal what value was bing printed, I can only conclude that either he is deliberatly having fun at our expense, or is incapable of understanding and following the simplest of requests.
Either way, I give up. Good luck Hans

when the program runs am asked to Enter the score:
For example 70
it prints
score: 70
INVALID

when the program runs am asked to Enter the score:
For example 70
it prints
score: 70
INVALID

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.