Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace apps
- {
- class Program
- {
- static void Main()
- {
- static int GetInput_Int() { return int.Parse(Console.ReadLine()); }
- //-----------------------------------------------------------------------------
- //-----------------------------------------------------------------------------
- //-----------------------------------------------------------------------------
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "END") { break; }
- else
- {
- Console.WriteLine($"{input} is {FindType(input)} type");
- }
- }
- }
- //-----------------------------------------------------------------------------
- static string FindType(string input)
- {
- string type = string.Empty;
- if (input == "true" || input == "false")
- {
- type = "boolean";
- }
- else
- {
- if (input.Length==1) // if the input is oonly 1 character it could be only int or char
- {
- if (char.IsDigit(input[0])) { type = "integer"; } else { type = "character"; }
- }
- else
- { // else it could be int, double or string
- if(input.Count(char.IsDigit) > 0 && input.Count(char.IsLetter) == 0)
- {
- if (input.Contains(".")) { type = "floating point"; } else { type = "integer"; }
- }
- if (input.Count(char.IsLetter) > 0) { type = "string"; }
- }
- }
- return type;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement