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;
- namespace Extended
- {
- class Program
- {
- static bool IsLetter(string str)
- {
- for (int i = 0; i < str.Length; i++)
- {
- if ((int)str[i] >= 65 && (int)str[i] <= 90 ||
- (int)str[i] >= 97 && (int)str[i] <= 122)
- {
- return true;
- }
- }
- return false;
- }
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string upOrLower = Console.ReadLine();
- List<char> ch = new List<char>();
- ch = input.ToList();
- int sum = 0;
- if (upOrLower == "UPPERCASE")
- {
- for (int i = 0; i < input.Length; i++)
- {
- if (IsLetter(input) && char.IsUpper(input[i]))
- {
- sum += (int)input[i];
- }
- }
- }
- else
- {
- for (int i = 0; i < input.Length; i++)
- {
- if (IsLetter(input) && char.IsLower(input[i]))
- {
- sum += (int)input[i];
- }
- }
- }
- Console.WriteLine("The total sum is: {0}", sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement