JAVA Admissions Admission to a professional course is subject to the following c
ID: 3669137 • Letter: J
Question
JAVA
Admissions
Admission to a professional course is subject to the following conditions:
Math score >=60 Physics score >=50 Chemistry score >=40
Total in all three subjects >=200 OR
Total in Math and Physics >= 150
Given the scores in the three subjects, write a program to process the applications to list the eligible candidates. You program should take input for the three scores for a given student and display their eligibility.
Plan of Attack
Step 1
For this program, I want to provide very little help, with a few hints.
Start with thinking about all the variables that will be needed. If I was doing this lab, I would declare at least five. I would use all integers.
Step 2
For the input I would read in at least 3 values using Scanner class for Math, Physics and Chemistry score.
Step 3:
Few hints here Your program should grant admission to a professional if and only if
Math score is greater than or equal to 60 and Physics score is greater than or equal to 50 and Chemistry score is greater than or equal to 40.
I would write a nested if statement for the next statement
(if total in all three subjects is >= 200) or (total in Math and Physics is >=150).
Step 4:
For output, I would make sure that you inform the student in detail why they are admitted in professional course or not.
Explanation / Answer
Solution:
package com.nancy.chegg;
import java.util.Scanner;
public class StudentEligibility {
public static void main(String[] args) {
int mathScore;
int phyScore;
int cheScore;
int total;
int totalMathPhy;
Scanner scanin = new Scanner(System.in);
System.out.println("Please enter scores below: ");
System.out.println("Math = ");
mathScore = scanin.nextInt();
System.out.println("Physics = ");
phyScore = scanin.nextInt();
System.out.println("Chemistry = ");
cheScore = scanin.nextInt();
total = mathScore + phyScore + cheScore;
totalMathPhy = mathScore + phyScore;
if (mathScore >= 60 && phyScore >= 50 && cheScore >= 40) {
if (total >= 200 || totalMathPhy >= 150) {
System.out.println("The student is eligible candidate. You are admitted in professional course");
} else {
System.out.println(
"Your total score for three subject in either less than 200 or the sum of math and physics is less than 150 so you are not admitted in professional course");
}
} else {
System.out.println(
"You are not eligible candidate.Because your score in math/physics /chemistry is less than 60/50/49 respectively.");
}
scanin.close();
}
}
Sample Run:
Please enter scores below:
Math =
66
Physics =
55
Chemistry =
44
Your total score for three subject in either less than 200 or
the sum of math and physics is less than 150 so you are not admitted in professional course
________________________________________________
Please enter scores below:
Math =
88
Physics =
77
Chemistry =
88
The student is eligible candidate.
You are admitted in professional course
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.