473,503 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Still need help for a riddle program!!!

13 New Member
Please I need urgent help with this program! Everything is working well except a part where i want to repeat the riddle if the answer isnt correct. here's the code..hope someone can help me!


Expand|Select|Wrap|Line Numbers
  1. import java.util.Scanner;
  2.  
  3. class TheRiddle {
  4.  
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String playername;
  9.         String riddleanswer;
  10.         char yesorno;
  11.  
  12.  
  13.     System.out.println("enigma!");
  14.     System.out.print("write your name: ");
  15.     playername = scanner.nextLine();
  16.     System.out.println("");
  17.     System.out.println("hey " + playername + ". blablabla" );
  18.     System.out.print("press 'Enter' when ready");
  19.     scanner.nextLine();
  20.     System.out.println("");
  21.  
  22.     do {System.out.println("riddle nº 1..blablabla");
  23.     riddleanswer = scanner.nextLine()}
  24.  
  25.     while (if (riddleanswer.equals("2") || riddleanswer.equals("two") {     
  26.             System.out.println("nice!");
  27.     } else {
  28.         System.out.println("Upss.."));        
  29.  
  30.     }
  31. System.out.print("press 'Enter' to continue");
  32.     scanner.nextLine();
  33.    System.out.println("");
  34.    System.out.println("2nd riddle...blablabla
  35.    riddleanswer = scanner.nextLine();
  36.  
  37.    scanner.nextLine();
  38.    System.out.println("");
  39.  
  40.  
  41.  
  42.     }
  43.  
  44.  
  45.         }
  46.  
  47.       }
  48.  
Same thing fot the second riddle...

Thanks
Feb 23 '08 #1
1 1729
Laharl
849 Recognized Expert Contributor
Please only create one thread per problem.

Your do loop needs a while condition, as specified in the link I posted in your other thread to Sun's Java tutorial.
Feb 23 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1953
by: MARTIN DAVIES | last post by:
I hope you can help. My Linux MYSQL 3.23.52 database server is working OK generally. However, in a database I have a field name that ends with a # (hash UK as opposed to £ which is a pound UK)...
13
2117
by: EggsAckley | last post by:
Hi: I have a file that I have been told is a SQL Server backup from a server somewhere. The file is about 200MB in size I am trying to create the database on my local server using RESTORE. I...
0
1463
by: Robert Oschler | last post by:
I have a database table with a field that is indexed as a "full-text" search, since I want the capabiity. However, I also want the ability to quickly retrieve records from that table that are ins...
2
2239
by: Jim | last post by:
I am a FoxPro programmer. What software do I need to program using MS access... I have apps that are non-web standalone and some web based... Do you recommend any learning resources? ...
45
1705
by: John Salerno | last post by:
Because of my 'novice-ness' in programming, I had always thought that C was replaced by C++ and wasn't really used anymore today. I know that's not the case at all now, but I'm still curious how...
1
3446
by: cheche | last post by:
hi, help me!!! i need hashing program in C or in Java.. tnx, cheche
8
2176
by: john | last post by:
To test a new piece of software designed to help with (among other things) eCommerce WWW site development. The software is fairly easy to use but you must fit a profile. Retail price is 120 GBP and...
2
3283
by: john sun | last post by:
Hi, Dear gurus, In the web deployment project, there is one option called "Output Assemblies page". The first choice is "Merge all outputs to a single assembly", According to MSDN, "Merges...
0
7204
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.