11 Mayıs 2016 Çarşamba

Csharp'ta While Örneği (1-2) -27

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace While
{
    class Program
    {
        static void Main(string[] args)
        {
            ///// ÖRNEK 1/2
            Console.Write("Hedef puanın nedir? : ");
            int hedef = int.Parse(Console.ReadLine());
            Console.Write("Hedefine kaçar kaçar girmek istiyorsun? : ");

            int kacarKacar = int.Parse(Console.ReadLine());

            int start = 0;
            Console.WriteLine(); Console.WriteLine();

            while (start < hedef & start + kacarKacar <= hedef)
            {
                start = start + kacarKacar;
                Console.WriteLine(start);
            }

            Console.WriteLine(); 
            Console.WriteLine(); 

            if (start != hedef)
            {
                Console.WriteLine("Girdiğin {0} sayısıyla hedefine ulaşman imkansız! \nİkinci girdiğin sayı, birinci girdiğin sayıya tam bölünmüyor!", kacarKacar);
            }
            if (start == hedef)
            {
                Console.WriteLine("Tebrikler, hedefine ulaştın!");
            }
            Console.ReadKey();
        }
    }
}



Hiç yorum yok:

Yorum Gönder