.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Number Game

Posted By:laptop charles       Posted Date: August 13, 2010    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  

Number game get a digit then will give the answer in previously .
 

*It just simply get the digit then will give the answer.
*then will give the two another input for same digit.
*then will give the answer is equal to both answer.
using System;
using System.Collections.Generic;
using System.Text;

namespace Number_game
{
    class Program
    {
        static void Main(string[] args)
        {
            int num,in1,in2,tot1;
            string  fin="";

            int totnum;

            int[] dig=new int[20];

            for (int i = 0; i <= 79; i++)
            {
                Console.Write("*");
            }
            Console.WriteLine("\t\t\t   NUMBER GAME BY CHARLES");
            for (int i = 0; i <= 79; i++)
            {
                Console.Write("*");
            }

            Console.WriteLine("\t\t\tEnter More Digit You Like ");
            Console.Write("\t\t\t");
            num = int.Parse(Console.ReadLine ());
            for (int i = 0; i <= 79; i++)
            {
                Console.Write("*");
            }
           
            totnum = int.Parse(2 + "" + (num));
            Console.WriteLine("\t\t\tAnswer Is  \" " + (totnum - 2)+"\"");
            
            for (int i = 0; i <= 79; i++)
            {
                Console.Write("*");
            }

       second:
            Console.WriteLine("\t\t\tEnter Another " + num.ToString().Length + " Digits");
            Console.Write("\t\t\t"); 
            in1 = int.Parse(Console.ReadLine ());
          
            if (num.ToString().Length == in1.ToString().Length)
           {
           thrid:
               Console.WriteLine("\t\t\tEnter Another " + num.ToString().Length + " Digits");
               Console.Write("\t\t\t");
               in2 = int.Parse(Console.ReadLine());
               if (num.ToString().Length == in2.ToString().Length)
               {
                   goto first;
               }
               else
               {
                   Console.WriteLine("\t\t\tInvalid Digit It Accept Only " + num.ToString().Length + " Digits");
                   goto thrid;
               }

           }
           else
           {
               Console.WriteLine("\t\t\tInvalid Digit It Accept Only " + num.ToString().Length + " Digits");
               goto second;
           }

          
      first:
          
           for (int i = 0; i < in1.ToString().Length; i++)
            {
              fin=9+""+fin;
            }

            tot1 = int.Parse(fin);

            for (int i = 0; i <= 79; i++)
            {
                Console.Write("*");
            }

            for (int i = 0; i <= 79; i++)
            {
                Console.Write("-");
            }
           
            Console.WriteLine("\t\t\t\t"+num);
            Console.WriteLine("\t\t\t\t"+in1);
            Console.WriteLine("\t\t\t\t"+(tot1 - in1));
            Console.WriteLine("\t\t\t\t"+in2);
            Console.WriteLine("\t\t\t\t"+(tot1 - in2));
            for (int i = 0; i <= 79; i++)
            {
                Console.Write("-");
            } 

            Console.WriteLine("Game Is Over See The Answer    " + (num + tot1 + tot1));
           
            for (int i = 0; i <= 79; i++)
            {
                Console.Write("-");
            }
            
            for (int i = 0; i <= 79; i++)
            {
                Console.Write("*");
            } 
            Console.ReadLine();

        }
    }
}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend