Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- System.out.println("welcome to the average calculator app");
- Scanner s = new Scanner(System.in);
- System.out.println("please enter your test score");
- int studentScore = s.nextInt();
- System.out.println("please enter the number of task's you did");
- int studentTask = s.nextInt();
- if (studentTask <= 4) {
- System.out.println("your score is: " + studentScore);
- 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
- }
- System.out.println("please enter the average score of your task's");
- int tasksAverage = s.nextInt();
- double average;
- // here we cover the range of tasks 5-7 and either over 60 or under it
- if (studentScore >= 60 && studentTask >= 5 && studentTask <= 7) {
- average = studentScore * 0.8 + tasksAverage * 0.2;
- System.out.println("your score is: " + (int) average);//
- } else if (studentScore <= 59 && studentTask >= 5 && studentTask <= 7) {
- average = studentScore * 0.9 + tasksAverage * 0.1;
- System.out.println("your score is: " + (int) average);
- }
- // here we cover the range of tasks 8 plus and if the score over 60 or under it
- if (studentTask >= 8 && studentScore >= 60) {
- average = studentScore * 0.7 + tasksAverage * 0.3;
- System.out.println("your score is: " + (int) average);
- } else if (studentScore < 60 && studentTask >= 8) {
- average = studentScore * 0.6 + tasksAverage * 0.4;
- System.out.println("your score is: " + (int) average);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement