Esercizi 27/11

 avatar
unknown
plain_text
3 years ago
2.5 kB
9
Indexable
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        /*
        -----ES 1
        int prezzo;
        int sconto = 2;
        float result;

        System.out.println("inserisci il prezzo");
        Scanner tastiera = new Scanner(System.in);
        prezzo = Integer.parseInt((tastiera.next()));
        System.out.println(prezzo);

        result = (prezzo * sconto) / 100;
        System.out.println("Il prezzo scontato è " + (prezzo-result)) ;


        -----ES 17
        boolean eBisestile = false;
        int anno;
        System.out.println("Inserire un anno");
        Scanner tastiera = new Scanner(System.in); //queste due
        anno = Integer.parseInt((tastiera.next())); //fanno il cin

        if (anno % 4 == 0 && anno % 100 != 0) {
            eBisestile = true;
        }

        if (anno % 400 == 0) {
            eBisestile = true;
        }

        if(eBisestile == true){
            System.out.println("quest'anno è bisestile");
        } else{
            System.out.println("non è bisestile");
        }


        ----ES14
        float array[] = new float[5];
        int i;
        Random rand = new Random();
        for(i=0;i<5;i++){
            array[i] = rand.nextFloat(0,1);
        }

        float media = 0;
        for(i=0;i<5;i++){
            System.out.println(array[i]);
        }
        media = media / 5;
        System.out.println("la media è " + media);


        ----ES15
        int area;
        int perimetro;
        int latoLungo;
        int latocorto;

        Scanner tastiera = new Scanner(System.in);
        System.out.println(" inserisci i lati del rettangolo: ");
        latoLungo = Integer.parseInt((tastiera.next()));
        latocorto = Integer.parseInt((tastiera.next()));
        area=latoLungo*latocorto;
        perimetro = 2*latoLungo + 2*latocorto;
        System.out.println("Il perimetro è " + perimetro + " e l'area è " + area);




        ----ES 33
        int array[] = new int[10];
        int i;
        int b;
        int conta=0;
        for(i=0;i<10;i++){
            Scanner tastiera = new Scanner(System.in); //queste due
            array[i]= Integer.parseInt((tastiera.next())); //fanno il cin
        }

        for(b=0;b<10;b++){
            if(array[b]>18){
                conta++;
            }
        }
        System.out.println(" i numeri maggiori di 18 sono : "+conta);
        */


    }
}
Editor is loading...