Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Slide61_Oef2 {
- public static void main(String[] args)
- {
- Scanner input=new Scanner(System.in);
- int getal, kleinst, grootst, aantal;
- System.out.print("Geef een getal (afsluiten door 0): ");
- getal = input.nextInt();
- //initialisatie van de variabelen
- kleinst = 2147483647;
- grootst = -2147483647;
- aantal = 0;
- while (getal != 0)
- {
- aantal += 1;
- if (getal > grootst)
- {
- grootst = getal;
- }
- if (getal < kleinst)
- {
- kleinst = getal;
- }
- System.out.print("Geef een getal (afsluiten door 0): ");
- getal = input.nextInt();
- }
- if (aantal == 0)
- {
- System.out.println("Er werden geen getallen ingegeven.");
- }
- else
- {
- System.out.println("Het grootste getal is " + grootst);
- System.out.println("Het kleinste getal is " + kleinst);
- }
- }
- }
Add Comment
Please, Sign In to add comment