26 lines
477 B
Java
26 lines
477 B
Java
|
|
||
|
public class Progression{
|
||
|
|
||
|
// attribut
|
||
|
private int compte;
|
||
|
// methode
|
||
|
public void plusUn() {
|
||
|
this.compte++;
|
||
|
}
|
||
|
// autre methode
|
||
|
public String toString() {
|
||
|
return Integer.toBinaryString(this.compte);
|
||
|
}
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
Progression n = new Progression();
|
||
|
n.compte = 5;
|
||
|
int s=5;
|
||
|
for(int i = 0;i<5;i++){
|
||
|
n.toString();
|
||
|
System.out.println("L'ecriture binaire de "+s+" est: "+n);
|
||
|
n.plusUn();
|
||
|
s++;
|
||
|
}
|
||
|
}
|
||
|
}
|