Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _10._Multiply_Evens_by_Odds
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = int.Parse(Console.ReadLine());
- number = Math.Abs(number);
- int multipleOfEvenAndOdds =
- GetMultipleOfEvenAndOdds(GetSumOfEvenDigits(number), GetSumOfOddDigits(number));
- Console.WriteLine(multipleOfEvenAndOdds);
- }
- static int GetSumOfEvenDigits(int number)
- {
- int sumEvenDigits = 0;
- while (number > 0)
- {
- int curruntDigit = number % 10;
- number /= 10;
- if (curruntDigit % 2 == 0)
- {
- sumEvenDigits += curruntDigit;
- }
- }
- return sumEvenDigits;
- }
- static int GetSumOfOddDigits(int number)
- {
- int sumOddDigits = 0;
- while (number > 0)
- {
- int curruntDigit = number % 10;
- number /= 10;
- if (curruntDigit % 2 != 0)
- {
- sumOddDigits += curruntDigit;
- }
- }
- return sumOddDigits;
- }
- static int GetMultipleOfEvenAndOdds(int sumOddDigits, int sumEvenDigits)
- {
- int multipleOfEvenAndOdds = sumOddDigits * sumEvenDigits;
- return multipleOfEvenAndOdds;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment