N
Newby
Gast
Hi ich hab mal eine frage! Ich will prüfen ob ein gegebener String nur die Römischen Ziffern enthält. Leider steht bei mir das die for schleife unsinnig ist, ich hoffe ihr könnt mir helfen.
public class ToDecimal {
String[] symbols = { "I", "V", "X", "L", "C", "D", "M" }; // lookup table
// for the
// symbols
// MUST'NT BE
// CHANGED!
int[] values = { 1, 5, 10, 50, 100, 500, 1000 }; // lookup table for the
// divisors MUST'NT BE
// CHANGED!
String I = "I";
public boolean StringReader(String Roman) {
for (int i = 0; i < Roman.length() - 1; i++) {
if (Roman.substring(i, i + 1) == "I"
|| Roman.substring(i, i + 1) == "V"
|| Roman.substring(i, i + 1) == "X"
|| Roman.substring(i, i + 1) == "L"
|| Roman.substring(i, i + 1) == "C"
|| Roman.substring(i, i + 1) == "D"
|| Roman.substring(i, i + 1) == "M") {
return true;
} else {
return false;
}
}
}
}
public class ToDecimal {
String[] symbols = { "I", "V", "X", "L", "C", "D", "M" }; // lookup table
// for the
// symbols
// MUST'NT BE
// CHANGED!
int[] values = { 1, 5, 10, 50, 100, 500, 1000 }; // lookup table for the
// divisors MUST'NT BE
// CHANGED!
String I = "I";
public boolean StringReader(String Roman) {
for (int i = 0; i < Roman.length() - 1; i++) {
if (Roman.substring(i, i + 1) == "I"
|| Roman.substring(i, i + 1) == "V"
|| Roman.substring(i, i + 1) == "X"
|| Roman.substring(i, i + 1) == "L"
|| Roman.substring(i, i + 1) == "C"
|| Roman.substring(i, i + 1) == "D"
|| Roman.substring(i, i + 1) == "M") {
return true;
} else {
return false;
}
}
}
}