0% found this document useful (0 votes)
8 views

Program

Uploaded by

idorazrazon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Program

Uploaded by

idorazrazon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

using System;

using System.Security.Principal;
class program
{
static void Main(string[] args)
{
Console.WriteLine("Targil logic prject");
bool A = true;
bool B = true;
bool C = true;
for (int i = 0; i < 4; i++)
{

Console.WriteLine("==========================================================");
Console.WriteLine(" - Targil {0} -
", i +1);
Console.WriteLine();
Console.Write("Enter the binary value for the first input:");
int num1 = int.Parse(Console.ReadLine());
while (true)
{
if (num1 == 0)
{
A = false;
break;
}
else if (num1 == 1)
{
A = true;
break;
}
Console.Write("Your answer is ineligible. What's the right value?
");
num1 = int.Parse(Console.ReadLine());
}
Console.Write("Enter the binary value for the second input:");
int num2 = int.Parse(Console.ReadLine());
while (true)
{
if (num2 == 0)
{
B = false;
break;
}
else if (num2 == 1)
{
B = true;
break;
}
Console.Write("Your answer is ineligible. What's the right value?
");
num2 = int.Parse(Console.ReadLine());
}
Console.Write("Enter the binary value for the third input:");
int num3 = int.Parse(Console.ReadLine());
while (true)
{
if (num3 == 0)
{
C = false;
break;
}
else if (num3 == 1)
{
C = true;
break;
}
Console.Write("Your answer is ineligible. What's the right value?
");
num3 = int.Parse(Console.ReadLine());
}
if (i == 0)
{
Console.WriteLine(targil1(A, B, C));
Console.WriteLine();
}
else if (i == 1)
{
Console.WriteLine(targil2(A, B, C));
Console.WriteLine();
}
else if (i == 2)
{
Console.WriteLine(targil3(A, B, C));
Console.WriteLine();
}
else
{
targil4(A, B, C);
Console.WriteLine();
}
}

public static bool targil1(bool a, bool b, bool c)


{
if (((a && b) ||(!b || c)) == true)
{
return true;
}
else
{
return false;
}
}
public static bool targil2(bool x, bool y, bool z)
{
if ((!(x || y) && !z) || ((x || y) && z)== true)
{
return true;
}
else
{
return false;
}
}
public static bool targil3(bool s1, bool s2, bool s3)
{
bool[] arr = new bool[8];
for (int i = 0; i < arr.Length; i++)
{
Console.Write("Enter the value for I{0} => ", i + 1);
int num = int.Parse(Console.ReadLine());
if (num == 0)
{
arr[i] = false;
}
else
{
arr[i] = true;
}
}
int total = 0;
if ( s1 == true)
{
total += 1;
}
if (s2 == true)
{
total += 2;
}
if (s3 == true)
{
total += 4;
}
return arr[total];
}

static void targil4(bool a1, bool a2, bool a3)


{
int total = 0;
if (a1 == true)
{
total += 1;
}
if (a2 == true)
{
total += 2;
}
if (a3 == true)
{
total += 4;
}
Console.WriteLine("the i{0} is true", total + 1);
}
}

You might also like