Please help me with the task: Exam task Fix Communication Module

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?

another version of the working code, still the platform does not accept it

using System;

namespace Exam
{
    class SecureFrequencies
    {
        static void Main()
        {
            bool finished = false;


            while (!finished)
            {
                string userInput = Console.ReadLine();


                if (userInput == "finished")
                {
                    finished = true;
                }

                else
                {
                    bool FrequencyIsSecureResult = FrequencyIsSecure(userInput);

                    if (FrequencyIsSecureResult == true)
                    Console.WriteLine("secure");

                    else
                    Console.WriteLine("insecure");
                }


            }
        }


        static bool FrequencyIsSecure(string userInput)
        {


            {
                int frequency = int.Parse(userInput);

                if (frequency % 5 != 0)

                {
                    return true;
                   
                }

                if (frequency % 5 == 0)
                {
                    return false;
                   
                }

                return true;

            }
        }
    }
}

The first thing I am seeing is that the task has the requirement “Write a method FrequencyIsSecure that takes an int with the name frequency”. Your method takes a string variable.

1 Like

Thanks! made changes, it works! :heart_eyes: