Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scuola;
- import java.util.*;
- public class IVA1 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner input;
- input=new Scanner (System.in);
- int cont=0, nprod;
- float pkg, kgs, frutta, spesa, tot = 0, min=9999999, sf=0;
- String reparto, minn = null;
- System.out.println("inserire numero prodotti acquistati:");
- nprod=input.nextInt();
- while (nprod>cont){
- cont=cont+1;
- System.out.println("inserire nome reparto");
- reparto=input.next();
- System.out.println("prezzo al kilo");
- pkg=input.nextFloat();
- System.out.println("inserire quantità di kg acquistati del prodotto");
- kgs=input.nextFloat();
- spesa=pkg*kgs;
- if(reparto.equals("frutta")){
- sf=spesa;
- }
- if (pkg<min){
- min=pkg;
- minn=reparto;
- }
- tot=tot+spesa;
- }
- System.out.println("spesa totale: "+tot);
- System.out.println("reparto più economica: "+minn);
- System.out.println("spesa reparto frutta: "+sf);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment