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:
using System;
namespace Exam
{
class SecureFrequencies
{
public static void Main()
{
// Write your code here
bool input = FrequencyIsSecure();
while (Console.ReadLine() != "finished")
{
if (input = false)
{
Console.WriteLine("secure");
}
else if (input = true)
{
Console.WriteLine("insecure");
}
}
}
public static bool FrequencyIsSecure()
{
int frequency = int.Parse(Console.ReadLine());
bool security;
if (frequency % 5 == 0)
{
security = false;
return security;
}
else
{
security = true;
return security;
}
}
}
}