Gebruiker:Yonatan17/Kladblok

2:

public class Huiswerk2 {

public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  System.out.println("Wat is getal 1?");
  double a = sc.nextDouble();
  System.out.println("Wat is getal 2?");
  double b = sc.nextDouble();
  System.out.println("Wat is getal 3?");
  double c = sc.nextDouble();
  System.out.println("Wat is getal 4?");
  double d = sc.nextDouble();
  System.out.println("Wat is getal 5?");
  double e = sc.nextDouble();
  double avg = (a + b + c + d + e) / 5;
  System.out.println("Het gemiddelde is: " + avg);
}

}


3:

public class Huiswerk3 {

public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  System.out.println("Wat is naam?");
  String name = sc.next();
  System.out.println("Wat is je snelheid in m/s?");
  double v = sc.nextDouble();
  System.out.println("Hoe lang doe je er over in s?");
  int t = sc.nextInt();
  double x = v * t;
  System.out.println(name + " woont " + x + "m van school af!");
}

}

4:


import java.util.Scanner;

public class IfElse {

public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  System.out.print("x = ");
  int x = sc.nextInt();
  int y;
  if (x > 5) {
    y = 6;
  } else if(x < 3) {
    y = 9;
  } else {
    y = 10;
  }
  System.out.println("y = " + y);
}

}