Advertisement
Guest User

task-5

a guest
May 24th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         System.out.println("welcome to the average calculator app");
  7.         Scanner s = new Scanner(System.in);
  8.         System.out.println("please enter your test score");
  9.         int studentScore = s.nextInt();
  10.         System.out.println("please enter the number of task's you did");
  11.         int studentTask = s.nextInt();
  12.         if (studentTask <= 4) {
  13.             System.out.println("your score is: " + studentScore);
  14.             return;//if task's is lower then 4 it shows the student score with out asking hes task average if not it just skips it
  15.         }
  16.  
  17.         System.out.println("please enter the average score of your task's");
  18.         int tasksAverage = s.nextInt();
  19.         double average;
  20.        
  21.         // here we cover the range of tasks 5-7 and either over 60 or under it
  22.         if (studentScore >= 60 && studentTask >= 5 && studentTask <= 7) {
  23.             average = studentScore * 0.8 + tasksAverage * 0.2;
  24.             System.out.println("your score is: " + (int) average);//
  25.         } else if (studentScore <= 59 && studentTask >= 5 && studentTask <= 7) {
  26.             average = studentScore * 0.9 + tasksAverage * 0.1;
  27.             System.out.println("your score is: " + (int) average);
  28.         }
  29.         // here we cover the range of tasks 8 plus and if the score over 60 or under it
  30.         if (studentTask >= 8 && studentScore >= 60) {
  31.             average = studentScore * 0.7 + tasksAverage * 0.3;
  32.             System.out.println("your score is: " + (int) average);
  33.         } else if (studentScore < 60 && studentTask >= 8) {
  34.             average = studentScore * 0.6 + tasksAverage * 0.4;
  35.             System.out.println("your score is: " + (int) average);
  36.         }
  37.  
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement