Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Permissions;
- using System.Text;
- using System.Threading.Tasks;
- namespace Struktury
- {
- internal class Program
- {
- struct Student
- {
- public string imie;
- public string nazwisko;
- public int wiek;
- public double sredniaOcen;
- }
- static void Main(string[] args)
- {
- Student[] student = new Student[3];
- int wybor;
- do
- {
- Console.Clear();
- Console.WriteLine("0 - Wyjście z programu");
- Console.WriteLine("1 - Dodawanie studentów");
- Console.WriteLine("2 - Wyświetlanie studentów");
- Console.Write("Twój wybor: ");
- wybor = int.Parse(Console.ReadLine());
- switch (wybor)
- {
- case 0:
- Console.Clear();
- Console.WriteLine("\n\n\n\n\n\n\n\n\t\t\t\t\t\tKONIEC");
- System.Threading.Thread.Sleep(1000);
- break;
- case 1:
- Console.WriteLine("Podaj dane studentów: ");
- for (int i = 0; i < student.Length; i++)
- {
- Console.WriteLine($"Student {i+1}:");
- Console.Write($"imie: ");
- student[i].imie = Console.ReadLine();
- Console.Write($"nazwisko: ");
- student[i].nazwisko = Console.ReadLine();
- Console.Write($"wiek: ");
- student[i].wiek = int.Parse(Console.ReadLine());
- Console.Write($"średnia ocen: ");
- student[i].sredniaOcen = double.Parse(Console.ReadLine());
- }
- break;
- case 2:
- for (int i = 0;i < student.Length;i++)
- Console.WriteLine($"Student: {student[i].imie} {student[i].nazwisko}, " +
- $"wiek {student[i].wiek}, średnia ocen: {student[i].sredniaOcen}");
- Console.ReadKey();
- break;
- default:
- Console.WriteLine("Nieodpowiedni wybór z menu!");
- Console.ReadKey();
- break;
- }
- } while (wybor != 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement