Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace DataTypeFinder
- {
- class Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine();
- bool isFloatingPointNumber = false;
- bool hasLetter = false;
- while (input != "END")
- {
- if (input == "true" || input == "false")
- {
- Console.WriteLine($"{input} is boolean type");
- }
- for (int i = 0; i < input.Length; i++)
- {
- if (input[0] == 45 && i > 0 && (input[i] <= 48 || input[i] > 57))
- {
- hasLetter = true;
- }
- else
- {
- if (input[i] == 44 || input[i] == 46)
- {
- isFloatingPointNumber = true;
- }
- }
- }
- if (!hasLetter)
- {
- if (isFloatingPointNumber)
- {
- Console.WriteLine($"{input} is floating point type");
- }
- else
- {
- Console.WriteLine($"{input} is integer type");
- }
- }
- if (input.Length == 1)
- {
- Console.WriteLine($"{input} is character type");
- }
- else if (input.Length > 1)
- {
- Console.WriteLine($"{input} is string type");
- }
- input = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement