wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Urgent help needed ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Urgent help needed !" Watch "Urgent help needed !" New topic

Urgent help needed !

Sa Dev

Joined: Mar 16, 2005
Posts: 3

I need to write a program consisting of a conversation between a computer and a person.

I should get results such as

Computer: What day is it today ?(A=Monday, B=Tuesday, C=Wednesday)
Person: A
Computer: What do you usually do on Mondays ?(A=..., B=...)
Person: B

[Note: Then if the person chooses A, another question should appear, for example : What do you normally do on mondays?(A=watch wrestling, B=play football, C=play tennis). If the person chooses 'B', i should have a question in relation with tuesday and same for 'C'. Hope u understand what i mean]

As if i should have a few sub-questions for each answer(Monday, Tues...)

But one thing is that i'm planning to have around 7 sub-questions per answer and don't know how to get back to the original question after the person answered the 7 sub questions of the first answer chosen.

The program should start like that:

public class ....
public static void main(String [] args)

What is mean is that it should use simple if...else statements and should have methods for calculation(for example: if person enters: 10 years and what to know how many days these 10 years equal to).

Please help me out, i badly need your help.

Thank You in advance.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Hi, welcome with your first post!

Figuring out how to organize code around a problem like this is great fun, so I won't jump in and provide details for you. I'll urge you DON'T PANIC, take it in small chunks, try something, see how you like it, be prepared to change it to work better later. As you gain experience you'll be able to see further ahead but for now see what's the simplest subset of the problem you can get working. Post some code and we'll try to help you progress one step at a time.
[ March 16, 2005: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
As this is probably an assignment, can't write any code. But a good design would be putting each "menu" inside its own method. This will help you separate all the menus, rather than putting them all in main().

What you need is one large loop, this is how you get back to the original question. Inside the loop, you could fire off to other questions by firing certain methods, then it will return and loop again.

Its actually quite simple, it just needs some thinking about structure.
Sa Dev

Joined: Mar 16, 2005
Posts: 3
Can i have more details ???

It's ok if you can't write the whole program down, but can someone please tell me how to create the if...else sequence. I really don't know how to do it with such a program. Please.

My email is : kleenex_7@hotmail.com . Please email me with some more precisions abt how to create the program.

Thanks in advance.
Joel McNary

Joined: Aug 20, 2001
Posts: 1817

What code do you have? We are willing to point out errors/make suggestions for improvements to current code, but we are not willing (and don't think that it's even a good idea) to do it for you.

Are you stuck on syntax or semantics? Syntax questions are easy:

But I don't really see how this would help you in acheiving this objective. Perhaps if you read about usinga Map, you could see a way to solve this.

Try writing some code and posting it here. We'll be more than happy to critique it.

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Sa Dev

Joined: Mar 16, 2005
Posts: 3
My problem actually is that when i answer the first question with "A", i will immediately get a second question and if i answer " B" in the first question, i still get the answer which is the "B" answer for the second question if i entered "A".

Here is part of my coding. It's not correct.Can u help me out

System.out.print("Computer: What day is it today?(a= monday, b= tuesday, C=wednesday)");

char answers;

answers= .readLineNonwhiteChar();

if(answers=='A' || answers=='a')

System.out.println("Person: A");
System.out.print("Computer: What do you do on mondays?(a=play soccer, b=watch wrestling, c=watch tv)");

char 2answers;


if(2answers=='A' || 2answers=='a')//Answer "A" for second question, which is first sub question.
System.out.println("Person: A");
System.out.println("Computer: You are very lazy...");

if(2answers=='B' || 2answers=='b')
System.out.println("Person: B");
System.out.println("Computer: You must go out more often");

[same thing for option c of that question]

if(answers=='B' || answers=='b')// Answer "B" for 1st question
System.out.println("Person: B");
System.out.print("Computer: What time do you normally wake up?(A= 10.00, B= 11.00, C = 12.00)");

char 3answers;

The programs goes on like that. What i also want to know is how to make the program end when it reaches around 10 sub questions ???

Can u please help me out as i'm new in java and have to solve that. Please !!!

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Sketching your program out as a zillion line long bit of logic is a good first step to get an idea of what must be done. But you can see it gets long and confusing and hard to change in a hurry. So start thinking about breaking things up.

Have you worked wtih for loops? The top level of your program could ask 10 questions with something as simple as this:

Please take a shot at what askAQuestion() might look like. We're happy to draw you along by asking more questions, but not to get too far ahead providing answers.
I agree. Here's the link: http://aspose.com/file-tools
subject: Urgent help needed !
Similar Threads
daysOfWeek function implementation
Dans exam
Help!! Please, need major help writing program!
Brackets problem