Form1.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace Filimonova_exam
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void btnAnsw_Click(object sender, EventArgs e)
  19. {
  20. int k = Convert.ToInt32(textA.Text); // для расчёта % пятёрок
  21. int m = Convert.ToInt32(textB.Text); // для расчёта % четвёрок
  22. int n = Convert.ToInt32(textC.Text); // для расчёта % троек
  23. int N = Convert.ToInt32(textN.Text); // общее количество студентов
  24. double p = (double)k/N * 100; //расчёт процента для 5
  25. double f = (double)n/N * 100; //расчёт процента для 4
  26. double h = (double)m/N * 100; //расчёт процента для 3
  27. double A = Math.Round(p,2);
  28. double B = Math.Round(f,2);
  29. double C = Math.Round(h,2);
  30. textAnswer1.Text = $"Процент троек = {C}";
  31. textAnswer2.Text = $"Процент четвёрок = {B}";
  32. textAnswer3.Text = $"Процент пятёрок = {A}";
  33. }
  34. }
  35. }