473,804 Members | 3,373 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with riddles prog

13 New Member
Hey, I hope you can help me with a prog i'm making. Everything is working well except a part where i want to repeat the riddle if the answer isnt correct. here's the bit of the bode where i need help
Expand|Select|Wrap|Line Numbers
  1.  
  2. System.out.println("Riddle:blablabla");
  3.     riddleanswer = scanner.nextLine();
  4.  
  5.     if (riddleanswer.equals("2") || riddleanswer.equals("two")) {        
  6.             System.out.println("Great!");
  7.     } else {
  8.         System.out.println("Upss..");
  9.  
well this way it would just finish the code once you get the wrong answer, but i need 2 repeat the riddle 2 be able 2 try again.

Thanks
Feb 23 '08 #1
10 1630
ImortalSorrow
13 New Member
Please need help!!...
Feb 23 '08 #2
JosAH
11,448 Recognized Expert MVP
Maybe a do { ... } while( ... ); loop can be of help here?

kind regards,

Jos
Feb 23 '08 #3
ImortalSorrow
13 New Member
ohh i get it, but can you help me with the code? im noob in programming so i dont exactly know what to put in the brackets you made. in this case what should i exactly do? should i erase the "if" and the "else" and do other code?
Feb 23 '08 #4
JosAH
11,448 Recognized Expert MVP
ohh i get it, but can you help me with the code? im noob in programming so i dont exactly know what to put in the brackets you made. in this case what should i exactly do? should i erase the "if" and the "else" and do other code?
A hint: your lines 1 and 2 should go between those curly brackets. The condition
in your if statement should go between the parentheses.

kind regards,

Jos
Feb 23 '08 #5
ImortalSorrow
13 New Member
ohh thanks a lot! ill try it
Feb 23 '08 #6
ImortalSorrow
13 New Member
ohh god i still cant do it.. i donno what i did wrong. i'll copy the entire code for you to see if there's anything wrong. hope some1 can help..
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.     }
  32. System.out.print("press 'Enter' to continue");
  33.     scanner.nextLine();
  34.    System.out.println("");
  35.    System.out.println("2nd riddle...blablabla
  36.    riddleanswer = scanner.nextLine();
  37.  
  38.    scanner.nextLine();
  39.    System.out.println("");
  40.  
  41.  
  42.  
  43.     }
  44.  
  45.  
  46.         }
  47.  
  48.                }
  49.  
Same thing fot the second riddle...

Thanks
Feb 23 '08 #7
ImortalSorrow
13 New Member
C'mon Please Someone!!...
Feb 23 '08 #8
ImortalSorrow
13 New Member
Help needed over here!!!!....
Feb 23 '08 #9
ImortalSorrow
13 New Member
OMG can anyone in this bloody comunity help me please?!?!...
Feb 23 '08 #10

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

Similar topics

7
12244
by: i_vincent | last post by:
Hi all, Newbie Python programmer here, so please be patient. I have spent all day googling for an answer to my problem, but everything I try fails to work (or works from the Interpreter with a set value but not from my code with dynamic values). Okay, here is the general gist of the problem. I am using Python to parse an output file (from a MAK Logger but that is not really important). Now I have some data that is contained on a line...
0
1715
by: Adam Haskell | last post by:
Ok heres the situation: We have a linked server from SQL 2000 to a foxpro dbf. In our test enviroment we had the Foxpro and SQL server on the same machine. The linked worked perfect. Now we are ready to implement it. When we made a link to the real FoxPro dbf nothing is showing up in the tables. The FoxPro is on a seperate machine under another domain in active Directory. We have tried on the same Active Directory as well, not
1
2697
by: Srinivasa Ra via .NET 247 | last post by:
(Type your message here) I am writing an application that does lot of read/write's withcomputer's serial port. The application as a whole is workingfine. Current Approach: I have a Timer that checks once every millisecond to see if there is any data avaialable to read at theserial port. If so then reads it. The serial port is openedwithout OVERLAPPING. TRYING TO GET TO: I don't think polling serial port every millisecond is a good approach....
25
1934
by: Mark | last post by:
I'm just starting out in an introductory ASP.Net course, and am trying to run a simple program but keeping getting an error. I'm running XP, have installed Internet Information Services (5.1) , Microsoft .Net Framework (English) v1.0.3705 and Microsoft .Net Framework SDK (English) v1.0a on my computer. Also Visual Studio .Net 2002 is also installed. "http://localhost/day1/listing0104.aspx" is placed in the address line of Browser. ...
1
1574
by: Arvind P Rangan | last post by:
Hi, I have created a class library which i need to use in my ASPX file. when i say: Dim mylib As TestLib = new TestLib() it gives me an error saying type required. How do we use a class library ?
0
282
by: saravanan_article | last post by:
Hi I am newbie to C#, i am using C# 2005 and DataGridView in my Application. The problem is described here I am using DataGrid and I placed some Headers like Column1,Column2,Column3.... What i want is i that i want to Create secondary column under the Column1(Col name) of dataGridView. Please share ur ideas.. Its very urgent. Is there any properties i need to set or any methods i need to override? Reply me as soon as possible
0
967
by: erekose666 | last post by:
I need to make a prog that will 1) Allow the user to select a make of car from a list of say 6 cars in an array I am assuming using get (I think) 2) Allow the user to select a predetermined trip (i.e. from Pittsburgh to New York) again from an array Im guessing using gets 3) Enter the current cost of a gallon of gas 4) Output should be something like A Nissan Sentra traveling from Pittsburgh to New York at a cost of $x per gallon will use...
5
1163
by: CodeTilYaDrop | last post by:
Hi Everyone, Could you share your experience on how to get better at solving problems. I am doing okay with the programming part, but I do not always pick the best algorithms for my problems. Do you have suggestions on how to get better at this? Where did some of you get so good at solving various problems?? Please help me out here. Thanks in advance -
8
9167
by: rdabane | last post by:
I'm trying to perform following type of operation from inside a python script. 1. Open an application shell (basically a tcl ) 2. Run some commands on that shell and get outputs from each command 3. Close the shell I could do it using communicate if I concatenate all my commands ( separated by newline ) and read all the output in the end. So basically I could do following sequence: 1. command1 \n command2 \n command 3 \n
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10310
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5515
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2983
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.