SHARE
TWEET

Notenmanager

a guest Feb 14th, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Notenmanager {
  4.     Scanner s1 = new Scanner(System.in);
  5.     String type;
  6.     int anzahlM;
  7.     int anzahlS;
  8.     int gesS;
  9.     int gesM;
  10.     boolean run = true;
  11.     double durchM;double durchS;double durchG;
  12.  
  13.     Notenmanager() {
  14.         notenBekommen();
  15.         System.out.println(notenBerechnen());
  16.     }
  17.  
  18.     void notenBekommen() {
  19.         while(run){
  20.             type = s1.next();
  21.             int note = s1.nextInt();
  22.             if (type.equals("S")) {
  23.                 anzahlS++;
  24.                 gesS += note;
  25.             } else if (type.equals("M")) {
  26.                 anzahlM++;
  27.                 gesM += note;
  28.             } else if (type.equals("=")) {
  29.                 run = false;
  30.                 break;
  31.             } else {
  32.                 throw new IllegalArgumentException("Keine Note dieses Typs vorhanden");
  33.             }
  34.         }
  35.     }
  36.  
  37.     double notenBerechnen(){
  38.         durchM = gesM/anzahlM;
  39.         durchS = gesS/anzahlS;
  40.         return durchG = (2*durchS+durchM)/(2*anzahlS+anzahlM);
  41.     }
  42.  
  43.     public static void main(String[] args) {
  44.         Notenmanager Mathe = new Notenmanager();
  45.  
  46.     }
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top