Write the following C programs ifelse statements Create a pr

Write the following C# programs. (if-else statements) Create a program that asks the user to type a value of type double. The program will say \"HALF\" if the number equals 0.5, and \"NOT - HALF\" otherwise. (if-else statements) Create a program that asks the user to type their age. If they are between 13 and 19 years old, then the program will say \"You are a teenager\". Otherwise, the program will say \"You are NOT a teenager\".

Solution

using System.IO;
using System;

class Program1
{
    static void Main()
    {
        double input;
      
        Console.WriteLine(\"Enter a double value : \");
        double.TryParse(Console.ReadLine(), out input);
      
        if (input == 0.5) {
            Console.WriteLine(\"HALF\");
        }
        else {
            Console.WriteLine(\"NOT-HALF\");
        }  
    }
}

---------------------------------------------------------------------------------------------------------

using System.IO;
using System;

class Program2
{
    static void Main()
    {
        int input;
      
        Console.WriteLine(\"Enter Your Age : \");
        int.TryParse(Console.ReadLine(), out input);
      
        if (input>=13 && input <=19) {
            Console.WriteLine(\"You are a teenager\");
        }
        else {
            Console.WriteLine(\"You are NOT a teenager\");
        }  
    }
}

 Write the following C# programs. (if-else statements) Create a program that asks the user to type a value of type double. The program will say \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site