Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06._Favorite_Movie
- {
- class Program
- {
- static void Main(string[] args)
- {
- int limit = 0;
- string bestMovie = "";
- int bestMovieSum = 0;
- int totalSum = 0;
- while (limit < 7)
- {
- totalSum = 0;
- string command = Console.ReadLine();
- if (command == "STOP")
- {
- Console.WriteLine($"The best movie for you is {bestMovie} with {bestMovieSum} ASCII sum.");
- break;
- }
- for (int i = 0; i < command.Length; i++)
- {
- if (command[i] == ' ')
- {
- totalSum += command[i];
- }
- if (command[i] >= 0 && command[i] <= 9)
- {
- totalSum += command[i];
- }
- if (command[i] >= 'a' && command[i] <= 'z')
- {
- totalSum += command[i] - (2 * command.Length);
- }
- if (command[i] >= 'A' && command[i] <= 'Z')
- {
- totalSum += command[i] - command.Length;
- }
- }
- limit++;
- if (totalSum > bestMovieSum)
- {
- bestMovie = command;
- bestMovieSum = totalSum;
- }
- }
- if (limit == 7)
- {
- Console.WriteLine("The limit is reached.");
- Console.WriteLine($"The best movie for you is {bestMovie} with {bestMovieSum} ASCII sum.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement