Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace lab12
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void buttonGenerate_Click(object sender, EventArgs e)
- {
- AB.Text = "A,2";
- AC.Text = "C,1";
- AD.Text = "A,1";
- BC.Text = "C,1";
- BD.Text = "B,1";
- CD.Text = "C,2";
- }
- private void calculPondere_Click(object sender, EventArgs e)
- {
- String[] input = new String[6];
- input[0] = AB.Text;
- input[1] = AC.Text;
- input[2] = AD.Text;
- input[3] = BC.Text;
- input[4] = BD.Text;
- input[5] = CD.Text;
- double SA = 0, SB = 0, SC = 0, SD = 0;
- for(int i=0;i<input.Length; ++i)
- {
- if(!input[i].Contains(","))
- {
- MessageBox.Show("error input");
- break;
- }
- if (input[i][0] == 'A')
- {
- SA += (input[i][2] - '0');
- }
- else if (input[i][0] == 'B')
- SB += (input[i][2] - '0');
- else if (input[i][0] == 'C')
- SC += (input[i][2] - '0');
- else if (input[i][0] == 'D')
- SD += (input[i][2] - '0');
- }
- double PA = SA / (SA + SB + SC + SD);
- double PB = SB / (SA + SB + SC + SD);
- double PC = SC / (SA + SB + SC + SD);
- double PD = SD / (SA + SB + SC + SD);
- double max = PA;
- string pmax = "PA";
- if (PB > max)
- {
- max = PB;
- pmax = "PB";
- }
- if (PC > max)
- {
- max = PC;
- pmax = "PC";
- }
- if (PD > max)
- {
- max = PD;
- pmax = "PD";
- }
- textBoxResult.Text = "Ponderea maxima este: " + pmax + " = " + (max*100).ToString() + "%";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement