2013-02-05, 19:29
#1
char bokstav = JOptionPane.showInputDialog(null, "Vilken bokstav vill du kontrollera?"); int count = 0; for (int i=0; i < ord.length(); i++) { if (ord.charAt(i) == bokstav) { count++; } }
if(inputWord.contains(inputLetter)){
String[] splitWord = inputWord.split(inputLetter, Integer.MAX_VALUE);
System.out.println("Det finns " (+ splitWord.length - 1) + " " + inputLetter + " i ordet " + inputWord);
} else {
System.out.println("Nepp, inget där!");
}
String input = JOptionPane//etc
char countChar = input.chatAt(0);
Scanner in = new Scanner(System.in); int count = 0; String sent = "fill me up"; System.out.println("Letter to search for:"); String slet = in.nextLine(); char letter= slet.charAt(0); for(int x = 0; x < sent.length(); x++) if(sent.charAt(x) == letter) count++; System.out.println(count + " " + letter + " was found");
case 5: //Kontrollerar om bokstav finns i ordet int antal; String getChar = JOptionPane.showInputDialog("Mata in den bokstav du vill kontrollera: "); for(int i = ord.length() -1; i>=0; i--) { if(getChar = ord.charAt(i)) { antal++; } } JOptionPaneshowMessageDialog(null, "Bokstaven " + getChar + " förekommer " + antal, " gånger i ordet!"); break;
case 5: //Kontrollerar om bokstav finns i ordet int antal = 0; String getChar = JOptionPane.showInputDialog("Mata in den bokstav du vill kontrollera: "); for(int i = ord.length() -1; i>=0; i--) { if(getChar.charAt(0) == ord.charAt(i)) { antal++; } } JOptionPane.showMessageDialog(null, "Bokstaven " + getChar + " förekommer " + antal + " gånger i ordet!");
case 5: //Kontrollerar om bokstav finns i ordet int antal; String getChar = JOptionPane.showInputDialog("Mata in den bokstav du vill kontrollera: "); for(int i = ord.length() -1; i>=0; i--) { if(getChar = ord.charAt(i)) { antal++; } } JOptionPaneshowMessageDialog(null, "Bokstaven " + getChar + " förekommer " + antal, " gånger i ordet!"); break;
Du måste vara medlem för att kunna kommentera
Flashback finansieras genom donationer från våra medlemmar och besökare. Det är med hjälp av dig vi kan fortsätta erbjuda en fri samhällsdebatt. Tack för ditt stöd!
Swish: 123 536 99 96 Bankgiro: 211-4106