Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Vacation
- {
- class Program
- {
- static void Main(string[] args)
- {
- string command = Console.ReadLine();
- while (command != "END")
- {
- if (command.ToLower() == "true" || command.ToLower() == "false")
- {
- Console.WriteLine($"{command} is boolean type");
- }
- else if (command.Length == 1 && (command[0] < '0' || command[0] > '9'))
- {
- Console.WriteLine($"{command} is character type");
- }
- else
- {
- bool isString = false;
- bool isFloatingPoint = false;
- bool isInt = false;
- int dotCounter = 0;
- for (int i = 0; i < command.Length; i++)
- {
- if ((i > 0 && command[i] == '-') || (i == 0 && command[i] == '.'))
- {
- isString = true;
- }
- else if ((command[i] >= '0' && command[i] <= '9') || command[i]=='-')
- {
- isInt = true;
- }
- else if (command[i] == '.')
- {
- dotCounter++;
- if (dotCounter == 1)
- {
- isFloatingPoint = true;
- }
- else
- {
- isString = true;
- }
- }
- else
- {
- isString = true;
- }
- }
- if (isString)
- {
- Console.WriteLine($"{command} is string type");
- }
- else if (isInt && isFloatingPoint)
- {
- Console.WriteLine($"{command} is floating point type");
- }
- else
- {
- Console.WriteLine($"{command} is integer type");
- }
- }
- command = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement