Jump to content

[Help]Java


Lineal

Recommended Posts

Hello , i am newbie in java programming and i need a bit help with a code that i wrote.

 

main idea : User give marks , for example school marks , and especially 4

 

First mark

Second Mark

Third Mark

Exams' Mark

 

and from the average the system will let the user know if the person who own the marks will " pass " or will "fail".

As i tested it works but only with Integers , for example if the average is 40.5 the program  will not work but if its an integer it will.!

 

here is the code

 

import java.util.Scanner;



public class GradeSystem{


public static void main(String[] args){


	Scanner input = new Scanner(System.in);


	int firstmark;
	int secondmark;
	int thirdmark;
	int exams;
	int average;


	System.out.print("Enter The First Mark");
	firstmark = input.nextInt();


	System.out.print("Enter The Second Mark");
	secondmark = input.nextInt();


	System.out.print("Enter The Third Mark");
	thirdmark = input.nextInt();


	System.out.print("Enter The Exams' Mark");
	exams = input.nextInt();


	average = (firstmark + secondmark + thirdmark + exams) / 4;

	if(average >= 100){
		System.out.printf("Student Pass");
	}
	else if(average <= 60){
		System.out.printf("Student Failed");
	}



}
}

 

any idea how to make it work with decimal numbers too?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...