B
BuHli-SoAD
Gast
Tag zusammen.. ich hab echt nicht viel ahnung von java aber wir müssen in der schule einige programme schreiben
Programm 1
Es sollen alle Teiler einer Zahl bestimmt werden
Porgamm 2
Polindrom ( soll lesen ob 1 wort/satz von vorne und von hinten gleich ist )
hier Prog 1.
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Teiler0 {
long zahl =1000;
public static void main(String args []) {
System.out.println("");
System.out.println("Programm zur Berechnung aller Teiler");
System.out.println("");
BufferedReader buf = new BufferedReader( new InputStreamReader(System.in));
System.out.print("Bitte geben Sie eine Zahl ein: ");
new Teiler0();
}
public Teiler0() {
System.out.println("");
System.out.println("");
System.out.println("Teiler der Zahl "+zahl);
for (long teiler =1; teiler<=zahl; teiler++) {
if ( ( zahl % teiler)==0)
System.out.print(" "+teiler);
}
System.out.println();
} // Konstruktor
} // class
<-- ich brauche hier HILFE für eine Eingabe.. d.h. ich will die Zahl selbst eingeben und sie soll nicht wie hier durch " long zahl = 1000 eingegeben werden...
hoffe mir kann jmd helfen
Porgramm 2
// Palindrome.java - check if a string is a palindrome
public class Palindrome {
public static void main(String[] args) {
String str1 = "eye", str2 = "bye";
System.out.println("Palindrome detection");
System.out.println(str1 + " "
+ isPalindrome(str1));
System.out.println(str2 + " "
+ isPalindrome(str2));
}
static boolean isPalindrome(String s) {
int left = 0;
int right = s.length() - 1;
while (left < right) {
if (s.charAt(left) != s.charAt(right))
return false;
left++;
right--;
}
return true;
}
}
<-- auch hier bräuchte ich ne eingabe für die wörter...
kann mir vllt jmd helfen? ich wär überaus dankbar!!!
Grüße
Tim
p.s. icq : 168890140
Programm 1
Es sollen alle Teiler einer Zahl bestimmt werden
Porgamm 2
Polindrom ( soll lesen ob 1 wort/satz von vorne und von hinten gleich ist )
hier Prog 1.
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Teiler0 {
long zahl =1000;
public static void main(String args []) {
System.out.println("");
System.out.println("Programm zur Berechnung aller Teiler");
System.out.println("");
BufferedReader buf = new BufferedReader( new InputStreamReader(System.in));
System.out.print("Bitte geben Sie eine Zahl ein: ");
new Teiler0();
}
public Teiler0() {
System.out.println("");
System.out.println("");
System.out.println("Teiler der Zahl "+zahl);
for (long teiler =1; teiler<=zahl; teiler++) {
if ( ( zahl % teiler)==0)
System.out.print(" "+teiler);
}
System.out.println();
} // Konstruktor
} // class
<-- ich brauche hier HILFE für eine Eingabe.. d.h. ich will die Zahl selbst eingeben und sie soll nicht wie hier durch " long zahl = 1000 eingegeben werden...
hoffe mir kann jmd helfen
Porgramm 2
// Palindrome.java - check if a string is a palindrome
public class Palindrome {
public static void main(String[] args) {
String str1 = "eye", str2 = "bye";
System.out.println("Palindrome detection");
System.out.println(str1 + " "
+ isPalindrome(str1));
System.out.println(str2 + " "
+ isPalindrome(str2));
}
static boolean isPalindrome(String s) {
int left = 0;
int right = s.length() - 1;
while (left < right) {
if (s.charAt(left) != s.charAt(right))
return false;
left++;
right--;
}
return true;
}
}
<-- auch hier bräuchte ich ne eingabe für die wörter...
kann mir vllt jmd helfen? ich wär überaus dankbar!!!
Grüße
Tim
p.s. icq : 168890140