|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Junior Member
Iscritto dal: Dec 2007
Messaggi: 23
|
[Java] Generazione numeri e caratteri
Ciao ragazzi. Ho questo codice:
Codice:
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner( System.in );
Random aGene = new Random();
Random intGene = new Random();
Random charUGene = new Random();
Random charLGene = new Random();
Generator myGene = new Generator();
int choice = input.nextInt();
for(int i = 0; i < choice; i++) {
int a = aGene.nextInt(3);
switch( a ) {
case 0: {
int x = intGene.nextInt(10);
System.out.printf("%d", myGene.getGeneratedInt(x));
break;
}
case 1: {
int x = charLGene.nextInt(26);
System.out.printf("%c", myGene.getGeneratedLChar(x));
break;
}
case 2: {
int x = charUGene.nextInt(26);
System.out.printf("%c", myGene.getGeneratedUChar(x));
break;
}
default: {
System.out.println("This program is perfect! :P");
break;
}
}
}
}
}
|
|
|
|
|
|
#2 |
|
Junior Member
Iscritto dal: Dec 2007
Messaggi: 23
|
Oops, un enhanced for scritto male. Grazie lo stesso.
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 10:42.



















