Guest User

Untitled

a guest
Jun 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  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.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         static int[] c = new int[5];
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.             random();
  19.         }
  20.         private double atlag()
  21.         {
  22.             double tmp=0;
  23.             for (int i = 0; i < c.Length; i++)
  24.             {
  25.                 tmp += c[i];
  26.             }
  27.             return tmp/5;
  28.         }
  29.         private void random()
  30.         {
  31.             Random r = new Random();
  32.             for (int i = 0; i < c.Length; i++)
  33.             {
  34.                 c[i] = r.Next(10, 100);
  35.             }
  36.             string a = "";
  37.             for (int i = 0; i < c.Length; i++)
  38.             {
  39.                 a = a + c[i].ToString() + " ";
  40.             }
  41.             label1.Text = a;
  42.         }
  43.         private void button1_Click(object sender, EventArgs e)
  44.         {
  45.             random();
  46.            
  47.         }
  48.         private void atlagos()
  49.         {
  50.             double f = atlag();
  51.  
  52.             if (f <= 50)
  53.             {
  54.                 label2.ForeColor = Color.Green;
  55.  
  56.             }
  57.             else
  58.             {
  59.                 label2.ForeColor = Color.Red;
  60.  
  61.             }
  62.             label2.Text = Convert.ToString(f);
  63.         }
  64.         private void button2_Click(object sender, EventArgs e)
  65.         {
  66.             atlagos();
  67.            
  68.         }
  69.     }
  70. }
Add Comment
Please, Sign In to add comment