Results 1 to 3 of 3
- 03-13-2012, 07:23 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 7
- Rep Power
- 0
how to make program that keeps score and loops till XXX is inputed
hi can some1 pls help me out im trying to make a program that loops till you type in xxx. i got that part done but the main goal of the program is that you need to type in a word and then the following word's first letter should start with the previous word's last letter for e.g. input:hello input:over input:rare input:xxx
output:score:3
if the word doesnt start with the previous word last letter it is counted as incorrect and if it starts with the last letter it is correct
later on the score = correct - incorect to get score here is my code pls help me out im strugling bad with this program
here is codeJava Code:String bgnword = JOptionPane.showInputDialog("Enter a begin word: "); int score; int len = bgnword.length(); score = 0; String word; int corwrd = 0; int incwrd = 0; String prevword = null; while(!"XXX".equals(word = JOptionPane.showInputDialog("Enter a word or XXX to quit."))) { char bgn = bgnword.charAt(len - 1); prevword = word; int len2 = word.length(); char ch1 = word.charAt(0); char ch2 = prevword.charAt(len2 - 1); if (prevword != null) { if(ch1 == ch2) { corwrd++; } else { incwrd--; } score = corwrd - incwrd; } } System.out.println("Score: " + score);Last edited by Norm; 03-13-2012 at 08:07 PM. Reason: added code tags
- 03-13-2012, 07:52 PM #2
Member
- Join Date
- Mar 2012
- Posts
- 7
- Rep Power
- 0
Re: how to make program that keeps score and loops till XXX is inputed
can any1 pls help me on this 1
- 03-13-2012, 08:07 PM #3
Re: how to make program that keeps score and loops till XXX is inputed
Please execute the program and Post the program's output here.
Add comments to the output saying what is wrong with it and show what the output should be.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.Last edited by Norm; 03-13-2012 at 08:09 PM.
Similar Threads
-
can i make a program to make keyboard and mouse idle or not responding for 10 second
By 3ammary in forum Advanced JavaReplies: 4Last Post: 07-23-2011, 08:08 PM -
I need a java program that takes scores and ouputs average, highest, and lowest score
By TheSweetHelloKitty in forum New To JavaReplies: 4Last Post: 02-15-2011, 11:05 PM -
How to make the actionPerformed be executed till the next Button click
By Laythe in forum AWT / SwingReplies: 9Last Post: 11-01-2009, 05:45 AM -
Basic high score program
By Implode in forum New To JavaReplies: 5Last Post: 09-03-2009, 05:21 PM -
Help combining loops into 1 program.
By kewlgeye in forum New To JavaReplies: 5Last Post: 04-22-2008, 09:58 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks