Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class GemiddeldeNeerslag {
- public static void main(String[] args) {
- System.out.println(new GemiddeldeNeerslag().calculateAverage());
- }
- private int[] neerslagarray = new int[12];
- public double calculateAverage() {
- int totaal = 0;
- for(int neerslag: neerslagarray) {
- totaal += neerslag;
- }
- return (double)(totaal)/12;
- }
- public GemiddeldeNeerslag() {
- Scanner scanner = new Scanner(System.in);
- for(int i = 0; i < 12; i++) {
- System.out.println("Geef de neerslag in voor maand " + (i + 1) + ":");
- int neerslag = scanner.nextInt();
- if(neerslag < 0)
- i--;
- else
- neerslagarray[i] = neerslag;
- }
- scanner.close();
- }
- }
- import java.util.Scanner;
- public class CamelCase {
- public static void main(String[] args) {
- new CamelCase();
- }
- public CamelCase() {
- Scanner scanner = new Scanner(System.in);
- String input;
- System.out.println("Geef invoer");
- while(!(input = scanner.next()).equals("STOP")) {
- if(isUppercase(input.charAt(0))) {
- System.out.println("Hoofdletter");
- } else {
- System.out.println("Kleine letter");
- }
- }
- scanner.close();
- }
- private static boolean isUppercase(char ch) {
- return (ch <= 'Z' && ch >= 'A');
- }
- }
- import java.util.HashMap;
- import java.util.Scanner;
- public class KleurCode {
- public static HashMap<Character,Integer> map = new HashMap<Character,Integer>();
- public static void loadConstants() {
- map.put('z',0);
- map.put('b',1);
- map.put('r',2);
- map.put('o',3);
- map.put('g',4);
- map.put('G',5);
- map.put('B',6);
- map.put('V',7);
- map.put('L',8);
- map.put('W',9);
- }
- /**
- * @param args
- */
- public static void main(String[] args) {
- loadConstants();
- Scanner scanner = new Scanner(System.in);
- String input;
- System.out.println("Geef invoer plz");
- while((input = scanner.next()).length() != 3 || invalidCode(input)) {
- System.out.println("Maak dat invoer 3 karakters lang is plz, geef opnieuw in plz");
- }
- scanner.close();
- System.out.println(new KleurCode(input.toCharArray()).getResistance());
- }
- public static boolean invalidCode(String s) {
- for(char ch: s.toCharArray()) {
- if(map.get(ch) == null)
- return true;
- }
- return false;
- }
- public KleurCode(char[] values) {
- this.a = map.get(values[0]);
- this.b = map.get(values[1]);
- this.c = map.get(values[2]);
- }
- public KleurCode(int a, int b, int c) {
- this.a = a;
- this.b = b;
- this.c = c;
- }
- public KleurCode(int[] values) {
- a = values[0];
- b = values[1];
- c = values[2];
- }
- private int a;
- private int b;
- private int c;
- public int getResistance() {
- return (a * 10 + b) * (int)Math.pow(10, c);
- }
- }
- import java.util.Scanner;
- public class Punten {
- public static final int SIZE = 20;
- public static void main(String[] args) {
- Punten punten = new Punten();
- punten.printInfo();
- }
- public void printInfo() {
- System.out.println("A's " + a + " B's " + b + " C's " + c + " Min :" + min + " Max: " + max);
- }
- private int a = 0;
- private int b = 0;
- private int c = 0;
- private int max = Integer.MIN_VALUE;
- private int min = Integer.MAX_VALUE;
- public Punten() {
- Scanner scanner = new Scanner(System.in);
- for(int i = 0; i < punten.length; i++) {
- int resultaat = scanner.nextInt();
- if(resultaat < 0) {
- i--;
- continue;
- }
- if(resultaat >= 12)
- a++;
- else if(resultaat >= 10)
- b++;
- else
- c++;
- if(resultaat > max)
- max = resultaat;
- else if(resultaat < min)
- min = resultaat;
- punten[i] = resultaat;
- }
- scanner.close();
- }
- private int[] punten = new int[SIZE];
- }
Add Comment
Please, Sign In to add comment