HelloWorld3.cs
1
/// So in this version of the hello program, we ask the user for his/her name, as well as
2
/// how many hours he/she slept last night. The user gets a different message depending on if
3
/// the hours are greater than 8.
4
​
5
​
6
using System;
7
​
8
namespace Hello
9
{
10
class Program
11
{
12
static void Main(string[] args)
13
{
14
Console.WriteLine("Please tell me ya name:");
15
string name = Console.ReadLine();
16
​
17
Console.WriteLine("Hey did you get enough sleep last night? Tell me how many hours (0-24):");
18
int hoursOfSleep = int.Parse(Console.ReadLine());
19
​
20
if(hoursOfSleep > 8)
21
{
22
Console.WriteLine("You are well rested!");
23
}
24
else
25
{
26
Console.WriteLine("Dude, you need more sleep!");
27
}
28
​
29
Console.WriteLine("Hey I made this in Visual Studio 2017 and did it especially for " + name);
30
Console.WriteLine("And regardless of if you got too much or too little sleep, you told me you got this many hours of sleep last night: " + hoursOfSleep);
31
}
32
}
33
}
34
​
Copied!
Copy link