THREE CORE SUBJECT ( QUESTION 2)

                INSTITUTE OF PUBLIC ADMINSTATION AND MANAGEMENT(IPAM)

MODULE: COMPUTER  PROGRAMMING

COURSE:BSC IN INFOMATION TECHNOLOGY

YEAR 1

BY: NAOMI BALAMA MOORE



import java.util.Scanner;
public class Grade{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int first_module;
int second_module;
int third_module;
System.out.println("welcome to your grade checker");
System.out.println("Enter the first grade module");
while (!input.hasNextInt()) {
System.out.println("Enter a whole number(grade) for the first module");
input.next();
}
first_module = input.nextInt();
while (first_module< 0|| first_module>100){
System.out.println("the number is out of the grading range");
while (!input.hasNextInt()){
System.out.println("Enter a whole number (grade) for your first module from 0-100");
input.next();
}
first_module = input.nextInt();
}
System.out.println("Enter the second grade module");
while (!input.hasNextInt()) {
System.out.println("Enter a whole number(grade) for the second module");
}
second_module = input.nextInt();
while(second_module < 0|| second_module > 100){
System.out.println("the number is out of the grading range");
while (!input.hasNext()){
System.out.println("Enter a whole number (grade) for your second module from 0-100");
input.next();
}
second_module = input.nextInt();
}
System.out.println("Enter the third grade module");
while (!input.hasNextInt()) {
System.out.println("Enter a whole number(grade) for the third module");
}
third_module = input.nextInt();
while (third_module < 0 || third_module > 100){
System.out.println("the number is out of the grading range");
while (!input.hasNext()){
System.out.println("Enter a whole number (grade) for your third module from 0-100");
input.next();
}
third_module = input.nextInt();
}

int all_modules = first_module + second_module + third_module;
int average = all_modules/3;
if (average>=70&& average<=100){
System.out.println("your average is:"+ "" + average + "" + "therefor you got 'A'");
} else if (average>=60&& average<=69){
System.out.println("your average is:"+ "" + average + "" + "therefor you got 'B'");
} else if (average>=50&& average<=59){
System.out.println("your average is:"+ "" + average + "" + "therefor you got 'C'");
} else if (average>=40&& average<=49){
System.out.println("your average is:"+ "" + average + "" + "therefor you got 'D'");
} else if (average>=0&& average<=39) {
System.out.println("your average is:" + "" + average + "" + "therefor you got 'F'");

}
}


}



Comments

Popular posts from this blog

COMPUTER PROGRAMMIG ASSIGNMENT

COMPUTER PROGRAMMING ASSIGNMENT 1&2

COMPUTER PROGRAMMING ASSIGNMENT