ok i got this exersice to do but i'm having a few problems, what i have to do is:
Write a program that asks the user to input a student exam mark, it then reads in the mark and displays the grade the student has. If the grade is less than 40 display FAILED, if it is between 40 and 50 display 3rd, if it is between 50 and 60 display 2/2 if it is between 60 and 70 display 2/1 and if it is over 70 display 1st. Make sure your program does not except invalid numbers – i.e. it should print out ‘invalid number’ if the user enters a number less than zero or greater than a hundred.
so this is the code I came up with:
/** This is a program to show the pass grade of a students mark between 0-100 Date:07/02/2011 Author:D.Rayner */ import java.util.Scanner; public class studentMarks { public static void main(String[] args) { int Mark; Scanner scan = new Scanner(System.in); System.out.println("enter student mark:"); Mark = scan.nextInt(); if (Mark <0); System.out.println("Invalid Number"); if (Mark >100); System.out.println("Invalid Number"); if (Mark <40); System.out.println("Failed"); if (Mark >=40); System.out.println("3rd"); if (Mark <50); System.out.println("3rd"); if (Mark >=50); System.out.println("2/2"); if (Mark <60); System.out.println("2/2"); if (Mark >=60); System.out.println("2/1"); if (Mark <70); System.out.println("2/1"); if (Mark >=70); System.out.println("1st"); } }
However when I run the program and enter a number it just prints all of the grades, for example if i put 51 it prints failed, 3rd, 2/2, 2/1, 1st and invalid number instead of just printing 2/2.
any help would be much appriciated.