Notes
Notes - notes.io |
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _02032019___Hüseyin_Karacif_Ödev
{
class Program
{
static string NumbersToRome(int number)
{
string transRome = string.Empty;
int birler = 0, onlar = 0, yuzler = 0, binler = 0;
string[] dBirler = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" };
string[] dOnlar = { "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" };
string[] dYuzler = { "", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" };
string[] dBinler = { "", "M", "MM"};
if (number < 10)
{
birler = number;
}
else if (9 < number && number < 100)
{
onlar = number / 10;
birler = number - (onlar * 10);
}
else if (99<number && number < 1000)
{
yuzler = number / 100;
onlar = (number - (yuzler * 100)) / 10;
birler = number - ((yuzler * 100) + (onlar * 10));
}
else if (999<number && number < 2501)
{
binler = number / 1000;
yuzler =(number - (binler * 1000)) / 100;
onlar = (number - ((binler * 1000) + (yuzler * 100))) / 10;
birler = number % 10;
}
transRome += dBinler[binler];
transRome += dYuzler[yuzler];
transRome += dOnlar[onlar];
transRome += dBirler[birler];
return transRome;
}
static bool MyTryParse(string value, out int number)
{
try
{
number= int.Parse(value);
if (number <= 0 || number > 2500)
{
return false;
}
return true;
}
catch (Exception)
{
number = 0;
return false;
}
}
static string SayıAl()
{
Console.Write("Roma Rakamına Çevirilecek Sayıyı Giriniz : ");
string transNumber = Console.ReadLine();
return transNumber;
}
static char DevamMı()
{
Console.WriteLine("YENİ İŞLEM YAPMAK İSTİYOR MUSUNUZ? (E/H)");
char harf = char.Parse(Console.ReadLine());
return harf;
}
static void Main(string[] args)
{
char harf = ' ';
string romeNumber = "";
int number;
do
{
string value = SayıAl();
if (MyTryParse(value, out number))
{
Console.Clear();
romeNumber = NumbersToRome(number);
Console.WriteLine("ÇEVİRDİM YENİ SAYIN : {0}",romeNumber);
harf = DevamMı();
}
else
{
Console.Clear();
Console.WriteLine("*******************************************");
Console.WriteLine("HARF VEYA NEGATİF SAYI GİRMEYİNİZ!!");
Console.WriteLine("GİRECEĞİNİZ EN BÜYÜK SAYI = 2500");
Console.WriteLine("GİRECEĞİNİZ EN KÜÇÜK SAYI = 1");
Console.WriteLine("*******************************************");
}
} while (harf != 'h' || harf != 'h');
Environment.Exit(0);
}
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team