-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTp1ej9
More file actions
43 lines (35 loc) · 1.17 KB
/
Tp1ej9
File metadata and controls
43 lines (35 loc) · 1.17 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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package tp1prog2;
import java.util.Scanner;
public class Tp1prog2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String letras[] = new String[10];
int aux1, cont = 0;
Scanner aux = new Scanner(System.in);
for(int i=0; i<10;i++){
System.out.println("Ingrese una letra: ");
letras[i] = aux.nextLine();
}
System.out.println("Ingrese cuantas veces se puede repetir una letra: ");
aux1 = aux.nextInt();
for(int p=0;p<10;p++){
for(int a=p; a<10;a++){
if(letras[a] == letras[p]){
cont += 1;
}
}
}
if(cont == aux1){
System.out.println("Se han repetido las mismas letras " + aux1 + " o mas veces");
}
else{
System.out.println("No se han repetido letras");
}
}
}