E
Extra Account
Guest
Hello,
I am new to Visual Studios C# and I am trying to write a code that describes a process of a machine. The program asks the user types in the current values of 2 sensors (0 for off, 1 for on). The problem that I am having is that when the user types a value of 0 for sensor 1 and a value of 1 for sensor 2, the program gives the output for sensor 1 and not sensor 2. I was wondering how I would do that? (I am using .NET framework in Visual Studios C#). Thanks in advance.
Here is a sample of my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Question_1_Program
{
class Program
{
static async Task Main(string[] args)
{
int x, y;
//User inputs the current value of sensors 1 & 2 using values 0 & 1 (0 = False/Off & 1 = True/On).
Console.WriteLine("Input the value for sensor one (0 = False/Off, 1 = True/On):");
x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Input the value for sensor two (0 = False/Off, 1 = True/On):");
y = Convert.ToInt32(Console.ReadLine());
if (x==1)
//Delay is added between each message.
Console.WriteLine("Turning off mixing motor 1. Please wait...");
await Task.Delay(2500);
Console.WriteLine("Closing valve 3, and opening valves 1 and 2. Please wait...");
await Task.Delay(2500);
Console.WriteLine("Filling up tank. Please wait...");
await Task.Delay(2000);
Console.WriteLine("Tank is 100% full!");
await Task.Delay(1200);
Console.WriteLine("Commencing shut down of valves 1 and 2. Please wait...");
await Task.Delay(1200);
Console.WriteLine("Valves 1 and 2 shutdown.");
//Paint has now reached sensor 2. Sensor 2's process begins.
if (y == 1)
Console.WriteLine("Ensuring valves 1, 2, and 3 are sealed. Please wait...");
await Task.Delay(2000);
Console.WriteLine("Valves 1, 2 and 3 are sealed. Preparing mixing motor. Please wait...");
await Task.Delay(4000);
Console.WriteLine("Mixing motor initialized. Please wait 60 seconds...");
await Task.Delay(60000);
Console.ReadLine();
}
}
}
Continue reading...
I am new to Visual Studios C# and I am trying to write a code that describes a process of a machine. The program asks the user types in the current values of 2 sensors (0 for off, 1 for on). The problem that I am having is that when the user types a value of 0 for sensor 1 and a value of 1 for sensor 2, the program gives the output for sensor 1 and not sensor 2. I was wondering how I would do that? (I am using .NET framework in Visual Studios C#). Thanks in advance.
Here is a sample of my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Question_1_Program
{
class Program
{
static async Task Main(string[] args)
{
int x, y;
//User inputs the current value of sensors 1 & 2 using values 0 & 1 (0 = False/Off & 1 = True/On).
Console.WriteLine("Input the value for sensor one (0 = False/Off, 1 = True/On):");
x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Input the value for sensor two (0 = False/Off, 1 = True/On):");
y = Convert.ToInt32(Console.ReadLine());
if (x==1)
//Delay is added between each message.
Console.WriteLine("Turning off mixing motor 1. Please wait...");
await Task.Delay(2500);
Console.WriteLine("Closing valve 3, and opening valves 1 and 2. Please wait...");
await Task.Delay(2500);
Console.WriteLine("Filling up tank. Please wait...");
await Task.Delay(2000);
Console.WriteLine("Tank is 100% full!");
await Task.Delay(1200);
Console.WriteLine("Commencing shut down of valves 1 and 2. Please wait...");
await Task.Delay(1200);
Console.WriteLine("Valves 1 and 2 shutdown.");
//Paint has now reached sensor 2. Sensor 2's process begins.
if (y == 1)
Console.WriteLine("Ensuring valves 1, 2, and 3 are sealed. Please wait...");
await Task.Delay(2000);
Console.WriteLine("Valves 1, 2 and 3 are sealed. Preparing mixing motor. Please wait...");
await Task.Delay(4000);
Console.WriteLine("Mixing motor initialized. Please wait 60 seconds...");
await Task.Delay(60000);
Console.ReadLine();
}
}
}
Continue reading...