Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package class170619;
- import java.util.Scanner;
- public class tester03 {
- public static void main(String[] args) {
- /*
- * סטודנט זכאי לגשת למבחן רק אם היה נוכח בלפחות 80% מהשיעורים. אחרת
- * ציונו הסופי בקורס הוא 0. אם הסטודנט עבר את המבחן בציון לפחות 60 ציון
- * הבוחן מהווה מגן של 20%. אם הסטודנט עבר את המבחן, ציון מטלות שיעורי
- * הבית מהוות 10% מהציון המשוקלל עם הבוחן.
- */
- // create scanner to get input data from user
- Scanner s = new Scanner(System.in);
- double attendance; // input: attendance percentage
- double finalGrade; // output: final grade
- // set final grade in case of failure
- finalGrade = 0;
- // get and save attendance percentage from user
- System.out.println("Enter student attendance percentage (0 to 100): ");
- attendance = s.nextDouble();
- if (attendance >= 80) {
- double testGrade;// grade of Test
- System.out.println("Enter grade of the test (0 to 100): ");
- testGrade = s.nextDouble();
- if (testGrade < 55) // failure: test grade is less than 55
- {
- finalGrade = testGrade;
- } else { // success: test grade is 55 or more
- double examGrade;// input: grade of exam
- double homeWorkGrade;// input: grade of Home Work
- // get and save grade of the exam
- System.out.println("Enter grade of the exam (0 to 100): ");
- examGrade = s.nextDouble();
- // get and save grade of Home Work
- System.out.println("Enter grade of Home Work (0 to 100): ");
- homeWorkGrade = s.nextDouble();
- // if exam helps then give it 20%
- finalGrade = examGrade > testGrade ? 0.2 * examGrade + 0.8
- * testGrade : testGrade;
- // calculate 10% for home work grade
- finalGrade = 0.9 * finalGrade + .1 * homeWorkGrade;
- }
- }
- // display result on the screen
- System.out.println("final grade is: " + finalGrade);
- s.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement