Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace NLoopsPartyInvitation
- {
- class NLoopsPartyInvitation
- {
- static void Main(string[] args)
- {
- string name = Console.ReadLine();
- int valid = 0;
- int invalid = 0;
- int counter = 0;
- while (name != "Statistic")
- {
- bool validName = true;
- counter++;
- foreach (char letter in name)
- {
- if (letter >='a' && letter <='z' || letter >= 'A' && letter<='Z')
- {
- name = name.Substring(0, 1).ToUpper() + name.Substring(1).ToLower();
- }
- else
- {
- name = "Invalid name!";
- validName = false;
- break;
- }
- }
- if (validName== false)
- {
- invalid++;
- }
- Console.WriteLine(name);
- name = Console.ReadLine();
- }
- valid = counter - invalid;
- double percentValid = valid * 100.0/counter;
- double percentInvalid = invalid * 100.0 / counter;
- Console.WriteLine("Valid names are {0:f2}% from {1} names.",percentValid,counter);
- Console.WriteLine("Invalid names are {0:f2}% from {1} names.",percentInvalid,counter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement