- import java.util.Scanner;
-
public class riddleGuess
-
{
-
public static void main (String[] args)
-
{
-
Scanner myScanner=new Scanner(System.in);
-
String[] question= new String[5];
-
String[] solution= new String[5];
-
String userAnswer= new String();
-
int times; times=0;
-
-
//initialize arays
-
question[0]=("I am weightless, but you can see me. Put me in a bucket, and I'll make it lighter. What am I?");solution[0]=("A hole");
-
question[1]=("I have hands that wave at you,/nThough I never say goodbye./nIt's cool for you to be with me,/nEspecially when I say, HI. What am I? ");solution[1]=("an electric fan");
-
question[2]=("Pronounced as one letter,/nAnd written with three,/nTwo letters there are,/nAnd two only in me./nI'm double, I'm single,/nI'm black, blue, and gray,/nI'm read from both ends,/nAnd the same either way./nWhat am I?");solution[2]=("eye");
-
question[3]=("You use a knife to slice my head and weep beside me when I am dead. What am I? ");solution[3]=("An onion");
-
question[4]=("What is the best way to keep your hat from falling off your head?");solution[4]=("don't put it on your head");
-
-
System.out.println("I AM THE SPHINX! PLAY MY GAME OF 5 RIDDLES AND I LET YOU LIVE! You've got three tries for each riddle!");
-
System.out.println("\n The first question is: \n" + question[0] + "\n");
-
-
-
for (times= 0; times < 3; times++)
-
{
-
String userAnwer=myScanner.nextLine();
-
System.out.println("You replied "+userAnswer);
-
}
-
if (!userAnswer.equals(solution[0]))
-
{
-
System.out.println("You got it wrong! Try again!");
-
}
-
else if (userAnswer==solution[0])
-
{
-
times=4; System.out.println("You got it right!");
-
}
-
}-
1 2428
You should use code tags when posting code. So what is the problem you are having with the code? Does it compile? Does it show errors when you run it?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: hoover_richard |
last post by:
I am a newbie to C++ and I need help with a simple program I am trying
to write. My program is designed to print all of the odd integers
contained in an array and output the sum of the odd...
|
by: Ian Davies |
last post by:
Hello
Needing help with a suitable solution.
I have extracted records into a table under three columns 'category',
'comment' and share (the category column also holds the index no of the
record...
|
by: Blackout |
last post by:
Hi,
I'm new to C and need to make a program that displays the output of the first six powers of 2 like this: 1 2 4 8 16 32
(2 to the power of 0, 2 to the power of 1, 2 to...
|
by: mike3 |
last post by:
(I'm xposting this to both comp.lang.c++ and comp.os.ms-
windows.programmer.win32
since there's Windows material in here as well as questions related to
standard
C++. Not sure how that'd go over...
|
by: xtheendx |
last post by:
I am writing a gradbook type program. It first allows the user to enter the number of students they want to enter. then allows them to enter the first name, last name, and grade of each student. The...
| |
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...
|
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...
|
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...
|
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,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| | |