Help with Console Application ( Holds conversations with user imput)

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
So im just messing around working on a console application, that you can ask questions and it will answer them using simple if/else statements..
But after i ask it one question it will not let me ask another, it will close after me typing in the next question and hitting enter
Here is my source:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Synthesis;
namespace LatestTvt
{
class Program
{
static void Main(string[] args)
{

// Initialize a new instance of the SpeechSynthesizer.
SpeechSynthesizer synth = new SpeechSynthesizer();
// Configure the audio output.
synth.SetOutputToDefaultAudioDevice();
//Start the opening Statement and Questions
Console.WriteLine("Hello, my name is Lucy, i am a computer program designed to keep simple conversations with people like you. Now i need to ask you a few questions to get to know you:");
synth.Speak("Hello, my name is Lucy, i am a computer program designed to keep simple conversations with people like you. Now i need to ask you a few questions to get to know you");
//Take the user input for there name
string userName;
//Taking the int for the age
int age;
Console.WriteLine("Please Enter Your Name");
synth.Speak("Please Enter Your Name");
userName = Console.ReadLine();
Console.WriteLine("Enter Your age");
synth.Speak("Enter Your age");
age = Convert.ToInt32(Console.ReadLine());
//Checking if there is age meets the reqierments
if (age < 10)
{
Console.WriteLine("Im Sorry {0} You are too young", userName);
synth.Speak(string.Format("Im sorry {0} you are too young", userName));
Console.ReadLine();
}
Console.WriteLine("Ask me some qestions {0}!", userName);
synth.Speak(string.Format("Ask me anything you would like {0}!", userName));
string line = Console.ReadLine();
//start the if statments
if (line == "what is your name")
{
Console.WriteLine("My name is Lucy, i am a computer generation conforsationilist");
synth.Speak("My name is Lucy, i am a computer generated conversationilist");
Console.ReadLine();
Console.ReadKey();
}
if (line == "were did you come from")
{
Console.WriteLine("I came from a couple simple lines of code made by Aaron Creager");
synth.Speak("I Came from a couple simple lines of code made by Aaron CReager");
Console.ReadLine();
Console.ReadKey();


}
if (line == "whats up")
{
Console.WriteLine("I am a computer program i dont really have anything to do, but talk to people like you {0}!", userName);
synth.Speak(string.Format("I am a computer program i dont really have anything to do, but talk to people like you {0}!", userName));
Console.ReadLine();
Console.ReadKey();

}
if (line == "what are you wearing")
{
Console.WriteLine("Well, i am just lines of c sharp code. I guess im not wearing anything");
synth.Speak(string.Format("Well, i am just lines of c sharp code. I guess im not wearing anthing"));


}
if (line == "how old are you")
{
Console.WriteLine("I am a growing sorce code, and i dont really remember when i was created");
synth.Speak("I am a growing sorce code, and i dont really remember when i was created");

}
else
{
Console.WriteLine("Im sorry i have not been taught that question yet {0}", userName);
synth.Speak(string.Format("Im sorry i have not been taught that question yet {0}", userName));
Console.ReadLine();
Console.ReadKey();
}
}
}
}

View the full article
 

Similar threads

Back
Top