ok i've been set a task to write a small C# program and heres the brief
"An Albanian social security number has a sequence of digits
followed by a letter. This 'check' letter is determined from
the values of the digits and is used to ensure that the numbers
are correct. Write a program that, when given a ten-digit
number and letter as input, calculates a unique 'check'
character corresponding to the given number according to the
following rules:
Add the five pairs of digits contained in the number
Take the remainder of dividing the result by 26
Select the letter in that position of the alphabet, starting
with 'A' in position 0, 'B' in position 1, and so on.
For example, if the input is 1122334455J, the program should
calculate (11 + 22 + 33 + 44 + 55) % 26 giving 9, and so 'J'
is the 'check' character. This means that the social security
number quoted is correct. If the input was 1122334455M, your
program should detect that the check letter is incorrect,
and therefore that this social security number is false."
This is what ive got so far
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CourseWork
{
class Program
{
static void Main(string[] args)
{
string socialNumber;
char check;
Console.WriteLine("please Write your social number without the letter."); //asks user to input social number without letter
string first = Console.ReadLine();
socialNumber = first.Substring(0, 10);
check = first[first.Length-1];
Console.WriteLine(check+socialNumber);
int sum = 0;
for (int i =0; i < socialNumber.Length-1; i++)
{
sum += Int32.Parse(socialNumber[i].ToString());
}
int remainder = sum % 26;
if (remainder == check)
{
Console.WriteLine("This is a correct number.. the check is {0} \\n the remainder is {1}", check, remainder);
}
else
{
Console.WriteLine("Please write your check letter.");
}
Console.WriteLine(sum);
Console.ReadLine();
}
}
}
So far i've asked the end user to input their social security number without the check letter.
What i can't get my head around is the division doesn't work and always returns the number 25 or it just closes the program. I don't know where to go from here >_< can somebody help me?