Minggu, April 03, 2011
di
07.33
|
class whileCount {
public static void main (String args[]) {
char input = (char) -1;
int numToCount;
System.out.println("Masukkan satu angka antara 0 dan 10: ");
try {
input = (char) System.in.read();
}
catch (Exception e) {
System.out.println("Error : " + e.toString());
}
numToCount = Character.digit(input, 10);
if ((numToCount > 0) && (numToCount < 10)) {
int i = 1;
while (i <= numToCount) {
System.out.println(i);
i++;
}
}
else System.out.println("Angka tsb tidak berada diantara 0 dan 10");
}
}
public static void main (String args[]) {
char input = (char) -1;
int numToCount;
System.out.println("Masukkan satu angka antara 0 dan 10: ");
try {
input = (char) System.in.read();
}
catch (Exception e) {
System.out.println("Error : " + e.toString());
}
numToCount = Character.digit(input, 10);
if ((numToCount > 0) && (numToCount < 10)) {
int i = 1;
while (i <= numToCount) {
System.out.println(i);
i++;
}
}
else System.out.println("Angka tsb tidak berada diantara 0 dan 10");
}
}
Diposting oleh
Unknown
0 komentar:
Posting Komentar