-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
50 lines (41 loc) · 1.44 KB
/
Program.cs
File metadata and controls
50 lines (41 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
namespace Modul2
{
class Program
{
// Dessa variabler behövs inte, för du har skapat lokala i main.
//STEG 1 definiera variabler du ska använda
static string name = "";
static int age;
static char letter;
//STEG 2 definiera metoder som behövs
static void Main(string[] args)
{
AskForInformation();
ReturnInformation();
}
//STEG 3
public static void AskForInformation() // Skulle göra en metod med ett namn som mer visar vad man gör.
{
Console.Write("What is your name? ");
name = Console.ReadLine();
// Lokal variabel.
Console.Write("How old are you? ");
age = int.Parse(Console.ReadLine());
Console.Write("What is your favorite letter? ");
letter = char.Parse(Console.ReadLine());
Console.WriteLine();
Console.WriteLine("Thank you!");
Console.WriteLine();
// Här kan du göra en ny metod som kallas ex. ReturningInput().
}
public static void ReturnInformation()
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.Write("Your name is: " + name);
Console.WriteLine("Your age is: " + age);
Console.WriteLine("Your favorite letter is: " + age);
Console.WriteLine();
}
}
}