-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibroMastro.java
More file actions
107 lines (70 loc) · 2.02 KB
/
LibroMastro.java
File metadata and controls
107 lines (70 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import java.util.Scanner;
public class LibroMastro {
private int venditeEffettutate;
private int venditeMax;
private double[] vendite;
LibroMastro(int venditeMassime) {
this.venditeMax = venditeMassime;
this.vendite = new double[venditeMax];
this.venditeEffettutate = 0;
}
public void aggiungiVendita(double d) {
if (this.venditeEffettutate < this.venditeMax) {
this.vendite[venditeEffettutate] = d;
this.venditeEffettutate++;
} else {
System.out.println("Vendite massime");
}
}
public int getNumeroVendite() {
return this.venditeEffettutate;
}
public double getTotaleVendite() {
double somma = 0;
for (int i=0; i<this.vendite.length; i++) {
somma += this.vendite[i];
}
return somma;
}
public void StampaVendite() {
for (int i=0; i<this.vendite.length; i++) {
System.out.println(this.vendite[i]);
}
}
public double getMedia() {
double somma = 0;
for (int i=0; i<this.vendite.length; i++) {
somma += this.vendite[i];
}
return somma / (vendite.length);
}
public void getVenditeAlDiSopra(double v) {
for (int i=0; i<this.vendite.length; i++) {
if(v < vendite[i])
System.out.println(vendite[i]);
}
}
public static void main(String[] args) {
LibroMastro prova1 = new LibroMastro(3);
Scanner tastiera = new Scanner(System.in);
double d;
do{
System.out.println("Aggiungi vendita:");
d =tastiera.nextDouble();
prova1.aggiungiVendita(d);
}
while (prova1.getNumeroVendite() < 3);
prova1.StampaVendite();
System.out.println("Totale Vendite!");
System.out.println(prova1.getTotaleVendite());
System.out.println("Media!");
System.out.println(prova1.getMedia());
double v;
System.out.println("dimmi una soglia");
v =tastiera.nextDouble();
System.out.println("Vendite al di sopra sono");
prova1.getVenditeAlDiSopra(v);
tastiera.close();
System.exit(0);
}
}