-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimoProgramma.java
More file actions
53 lines (33 loc) · 1.03 KB
/
PrimoProgramma.java
File metadata and controls
53 lines (33 loc) · 1.03 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
import java.util.Scanner;
public class PrimoProgramma {
enum Punteggio {A, B, C}
public static void main(String[] args) {
Scanner Tastiera = new Scanner(System.in);
String s1, s2;
System.out.println("Ciao");
System.out.println("Inserisci la stringhe:");
s1 = Tastiera.nextLine();
s2 = Tastiera.nextLine();
//metodo alternativo per scrivere if - else
String s3 = (s1.equals(s2)) ? s1 : s2;
if (s1.equals(s2)) {
System.out.println("Le stringhe sono uguali");
System.exit(0);
} else {
System.out.println("No non sono uguali");
}
if (s1.equalsIgnoreCase(s2)) {
System.out.println("Le stringhe sono uguali senza considerare il maiusc");
} else {
System.out.println("Le stringhe non sono uguali anche con il maiusc");
}
System.out.println(s3);
String s1Up = s1.toUpperCase();
String s2Up = s2.toUpperCase();
if (s1Up.compareTo(s2Up) < 0) {
System.out.println(s1 + " Segue in ordine alfabetico " + s2);
} else {
System.out.println(s2 + "Segue in ordine alfabetico" + s1);
}
}
}