-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestRazionale.java
More file actions
39 lines (34 loc) · 1.05 KB
/
TestRazionale.java
File metadata and controls
39 lines (34 loc) · 1.05 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
package prg.es3;
import java.util.Scanner;
public class TestRazionale{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Razionale r1 = new Razionale();
Razionale r2 = new Razionale();
System.out.println("PRIMO NUMERO RAZIONALE:");
System.out.print("Inserisci Numeratore: ");
r1.setNum(input.nextInt());
try{
System.out.print("Inserisci Denominatore: ");
r1.setDen(input.nextInt());
} catch(IllegalArgumentException exp){
r1.setDen(1);
System.out.println("Denominatore impostato a 1");
}
System.out.println("SECONDO NUMERO RAZIONALE:");
System.out.print("Inserisci Numeratore: ");
r2.setNum(input.nextInt());
System.out.print("Inserisci Denominatore: ");
r2.setDen(input.nextInt());
r1.toPrint();
r2.toPrint();
System.out.print("Somma: ");
r1.somma(r2).toPrint();
System.out.print("Sottrazione: ");
r1.sottrai(r2).toPrint();
System.out.print("Prodotto: ");
r1.product(r2).toPrint();
System.out.print("Divisione: ");
r1.divide(r2).toPrint();
}
}