Hello, I’m working on this task:
Your task is to fix a communications module for our drones. Basically, it usually works, but sometimes it uses unsecured radio frequencies to communicate. This could allow the signal to be intercepted by machines and used against humanity. We learned that the only safe frequencies are NOT divisible by 5. Therefore, all frequencies that are divisible by 5 are considered insecure. Write a method FrequencyIsSecure that takes an int with the name frequency — the frequency that the drone is using to communicate to others, and returns a bool — whether that frequency is secure or not. Read integer numbers from the input — frequencies of the communication channel, and for every one of them use the FrequencyIsSecure method to output “secure” or “insecure”. When you read “finished” from the console, the program should terminate.
For example:
>4
secure
>5
insecure
>9
secure
>11
secure
>20
insecure
>finished
Here is my code:
namespace Exam
{
class SecureFrequencies
{
static void Main()
{
bool finished = false;
while (!finished)
{
string userInput = Console.ReadLine();
if (userInput == "finished")
{
finished = true;
}
else
{
FrequencyIsSecure(userInput);
}
}
}
static bool FrequencyIsSecure(string userInput)
{
{
int frequency = int.Parse(userInput);
if (frequency % 5 != 0)
{
Console.WriteLine("secure");
}
if (frequency % 5 == 0)
{
Console.WriteLine("insecure");
}
return true;
}
}
}
}
Can anyone please help me to solve it?