Last active
May 3, 2017 13:28
-
-
Save mattiaferigutti/bdb1e38aa245c2143c8f7e9c3ce61aad to your computer and use it in GitHub Desktop.
nome cognome con tabella
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Mattia on 03/05/2017. | |
*/ | |
public class NomeClass | |
{ | |
private String nome; | |
private String cognome; | |
private int[] arrayTabella = new int[10]; | |
public NomeClass(String nome, String cognome) | |
{ | |
this.nome = nome; | |
this.cognome = cognome; | |
} | |
public void InvertiTabella() | |
{ | |
System.out.println("\ncognome: " + cognome + " - nome: " + nome); | |
//SALVATAGGIO NELL'ARRAY E STAMPA DELLA TABELLA | |
int a=0; | |
for (int i=0; i<(cognome.length())*10; i+=cognome.length(), a++) | |
{ | |
System.out.println("tabella: " + i); | |
arrayTabella[a] = i; | |
} | |
// STAMPA DEL SALVATAGGIO NELL'ARRAY | |
for (int i=0; i<arrayTabella.length; i++) | |
{ | |
System.out.println(arrayTabella[i]); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
/** | |
* Created by Mattia on 03/05/2017. | |
*/ | |
public class NomeProg | |
{ | |
public static void main(String... args) | |
{ | |
Scanner scan = new Scanner(System.in); | |
System.out.print("Inserisci nome: "); | |
String nome = scan.next(); | |
System.out.print("Inserisci cognome: "); | |
String cognome = scan.next(); | |
NomeClass nomeClass = new NomeClass(nome, cognome); | |
nomeClass.InvertiTabella(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment