Im trying to make it so that I can't to out put as the example! is only:
S: - - - - ; A: - A - A ; V: - - V -; J : J - - -
Help Please ME!
Thank you very much!
- - - -
S
- - - -
A
- A - A
V
- A V A
D
- A V A
J
J A V A
Bingo! You won.
This is my program:
import java.util.*;
class GuessWordJava {
public static void main ( String[] args ){
Scanner scanner = new Scanner(System.in);
System.out.print("\n Enter secret entence : ");
String sentence = scanner.next();
int length = sentence.length();
while( true) {
char letter;
System.out.print("\n Enter your guess : ");
char ch = scanner.next().charAt(0);
if ( ch == ' ') {break;}
String str="";
for (int i = 0; i < length; i++){
letter = sentence.charAt(i);
if ( letter == ch ){
str=str+letter;
} else {
str= str+ "-";
}
}
System.out.print(str);
}
}
}
This post has been edited by jon.kiparsky: 24 May 2012 - 09:09 AM
Reason for edit:: added code tags

New Topic/Question
Reply



MultiQuote






|