|
public class Cirkels {
public static double oppervlakte(double r){ return r*r*Math.PI;} public static void main(String[] args) { char kar; double straal,max=0; int aantal=0,goed=0,slecht=0; Input inp=new Input(); System.out.println("geef 'j' in voor een nieuwe cirkel"); kar=inp.readChar(); while (kar=='j') {aantal++; System.out.println("geef de straal in"); straal=inp.readDouble(); if(straal>0){ System.out.println("cirkel "+aantal+":\t straal: "+straal+"\t oppervlakte "+oppervlakte(straal)); goed++; if(oppervlakte(straal)>max) max=oppervlakte(straal);} else {slecht++;System.out.println("straal moet positief zijn");} System.out.println("geef 'j' in voor een nieuwe cirkel"); kar=inp.readChar(); kar=inp.readChar();} System.out.println("geef 1 in voor aantal goed invoeren, 2 voor slechte invoeren, 3 voor totaal aantal invoeren, 4 voor grootste oppervlakte, ander getal voor te stoppen"); int cijfer=inp.readInt(); while(cijfer>=1&&cijfer<=4) {switch(cijfer) {case 1: System.out.println("aantal goede: "+goed);break; case 2: System.out.println("aantal slechte: "+slecht);break; case 3: System.out.println("totaal: "+aantal);break; case 4:System.out.println("grootste oppervlakte: "+max);break;} System.out.println("geef 1 in voor aantal goed invoeren, 2 voor slechte invoeren, 3 voor totaal aantal invoeren, 4 voor grootste oppervlakte, ander getal voor te stoppen"); cijfer=inp.readInt();}}}
|