E
Extra Account
Guest
Hello,
I am fairly new to visual studios C# and I was wondering if it was possible to add a countdown timer that showed the numbers being counted down from 60 seconds to 0 seconds in this program? If so how would I go about doing that? (I am using Visual studios C# 2019 .NET Framework).
Thanks in advance.
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("Ensuring that mixing motor is off. 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("Mixing 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.");
await Task.Delay(1000);
Console.WriteLine("Current value for valve 1 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for valve 2 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for valve 3 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for mixing motor is: 0 (False/Off).");
}
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...");
//Add 60 second timer here.
await Task.Delay(2000);
Console.WriteLine("Commencing shutdown of mixing motor. Please wait...");
await Task.Delay(2000);
Console.WriteLine("Mixing motor shutdown. Opening valve 3. Please wait...");
await Task.Delay(1500);
Console.WriteLine("Valve 3 opened. Transfering paint to storage tank. Please wait...");
await Task.Delay(4000);
Console.WriteLine("All paint has been successfully transfered to storage tank. Shutting off valve 3. Please wait...");
await Task.Delay(2000);
Console.WriteLine("Valve 3 is sealed. Mixing tank is now 0% full.");
await Task.Delay(2000);
Console.WriteLine("Current value for valve 1 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for valve 2 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for valve 3 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for mixing motor is: 0 (False/Off).");
}
Console.ReadLine();
}
}
}
Continue reading...
I am fairly new to visual studios C# and I was wondering if it was possible to add a countdown timer that showed the numbers being counted down from 60 seconds to 0 seconds in this program? If so how would I go about doing that? (I am using Visual studios C# 2019 .NET Framework).
Thanks in advance.
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("Ensuring that mixing motor is off. 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("Mixing 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.");
await Task.Delay(1000);
Console.WriteLine("Current value for valve 1 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for valve 2 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for valve 3 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for mixing motor is: 0 (False/Off).");
}
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...");
//Add 60 second timer here.
await Task.Delay(2000);
Console.WriteLine("Commencing shutdown of mixing motor. Please wait...");
await Task.Delay(2000);
Console.WriteLine("Mixing motor shutdown. Opening valve 3. Please wait...");
await Task.Delay(1500);
Console.WriteLine("Valve 3 opened. Transfering paint to storage tank. Please wait...");
await Task.Delay(4000);
Console.WriteLine("All paint has been successfully transfered to storage tank. Shutting off valve 3. Please wait...");
await Task.Delay(2000);
Console.WriteLine("Valve 3 is sealed. Mixing tank is now 0% full.");
await Task.Delay(2000);
Console.WriteLine("Current value for valve 1 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for valve 2 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for valve 3 is: 0 (False/Off).");
await Task.Delay(1000);
Console.WriteLine("Current value for mixing motor is: 0 (False/Off).");
}
Console.ReadLine();
}
}
}
Continue reading...