Practice: Creating Classes
Write code for creating a class called Employee
which can store the name, age and salary of an employee. The age will be an integer value while the salary will be a double.
index.cs
12345678910111213141516171819using System; // Write class code below this line // Write class code above this line public class ConsoleApp { public static void Main(string[] args) { Employee e1 = new Employee(); e1.name = "Jenny"; e1.age = 32; e1.salary = 70000.0; Console.WriteLine($"{e1.name} is {e1.age} years old and she earns ${e1.salary} per year."); } }
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 3. Kapittel 3
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 2.04
Practice: Creating Classes
Sveip for å vise menyen
Write code for creating a class called Employee
which can store the name, age and salary of an employee. The age will be an integer value while the salary will be a double.
index.cs
12345678910111213141516171819using System; // Write class code below this line // Write class code above this line public class ConsoleApp { public static void Main(string[] args) { Employee e1 = new Employee(); e1.name = "Jenny"; e1.age = 32; e1.salary = 70000.0; Console.WriteLine($"{e1.name} is {e1.age} years old and she earns ${e1.salary} per year."); } }
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 3. Kapittel 3