TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tito Onowu
NA
37
8.8k
Subtracting user input
Nov 6 2013 5:20 AM
Good day teachers. Am back again. Was trying to get this program to tell me how many steps has been taken from one point to the other. There should be 64 squares (A-H, 1-8)and can move from one point A to H by numerical identification.moving toward the left might be negative or from the middle downwards but all outcome regardless the sign should be positive. This is where i got and am still thinking how to make out the logic to get the right result.
Thanks.
string pos0;
string pos1;
int move;
do
{
Console.WriteLine(@"Enter King's position, A-H 1-8 : ");
pos0 = Console.ReadLine().ToUpper();
}
while(pos0.Length != 2 ||
!(pos0[0] >= 'A' && pos0[0] <= 'H') ||
!(pos0[1] >= '1' && pos0[1] <= '8'));
Console.WriteLine(@"King's position is: ");
Console.WriteLine();
do
{
Console.WriteLine(@"Enter the position where King needs to be, A-H 1-8 : ");
pos1 = Console.ReadLine().ToUpper();
}
while (pos1.Length != 2 ||
!(pos1[0] >= 'A' && pos1[0] <= 'H') ||
!(pos1[1] >= '1' && pos1[1] <= '8'));
Console.WriteLine(@"King's position is: ");
Console.WriteLine();
move = pos0[1] - pos1[1];
Console.WriteLine("King moved: ", move);
Console.ReadKey ();
Reply
Answers (
2
)
Delegates Vs Class
Date in Sql server 2008