private: System::Void comboBox2_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void comboBox3_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
try
{
double baseRate = Convert::ToDouble(textBox1->Text);
double kbm = Convert::ToDouble(textBox2->Text);
int accidents = Convert::ToInt32(textBox3->Text);
double kt = GetKT(comboBox1->SelectedIndex);
double kvs = GetKVS(comboBox2->SelectedIndex);
double km = GetKM(comboBox3->SelectedIndex);
double months = Getmonths(comboBox4->SelectedIndex);
bool limitedDrivers = checkBox1->Checked;
double ko = limitedDrivers ? 1.0 : 1.8;
double price = baseRate;
price *= kt;
price *= kbm;
price *= kvs;
price *= ko;
price *= km;
price *= months;
if (accidents >= 3) price *= 1.50;
else if (accidents == 2) price *= 1.25;
else if (accidents == 1) price *= 1.10;
price = Math::Round(price, 2);
String^ result = "РАСЧЁТ ПОЛИСА ОСАГО\n\n";
result += "ИТОГОВАЯ СТОИМОСТЬ: " + price.ToString() + " ₽";
MessageBox::Show(result, "Результат расчёта ОСАГО",
MessageBoxButtons::OK, MessageBoxIcon::Information);
}
catch (Exception^ ex)
{
MessageBox::Show("Ошибка! Проверьте, что все поля заполнены правильно.\n\n" + ex->Message,
"Ошибка ввода", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
}
double GetKT(int index)
{
switch (index)
{
case 0: return 1.24; // Великий Новгород
case 1: return 1.16; // Псков
case 2: return 1.00; // Боровичи
case 3: return 1.64; // Санкт-Петербург
case 4: return 1.80; // Москва
default: return 1.0;
}
}
double GetKVS(int index)
{
switch (index)
{
// 18-21 год
case 0: return 2.27;
case 1: return 1.92;
case 2: return 1.84;
case 3: return 1.65;
// 22-24 года
case 4: return 1.88;
case 5: return 1.72;
case 6: return 1.71;
case 7: return 1.13;
case 8: return 1.10;
case 9: return 1.09;
// 25-29 лет
case 10: return 1.72;
case 11: return 1.60;
case 12: return 1.54;
case 13: return 1.09;
default: return 1.0;
}
}
double GetKM(int index)
{
switch (index)
{
case 0: return 0.6;
case 1: return 1.0;
case 2: return 1.1;
case 3: return 1.2;
case 4: return 1.4;
case 5: return 1.6;
default: return 1.0;
}
}
double Getmonths(int index)
{
switch (index)
{
case 0: return 0.5;
case 1: return 0.6;
case 2: return 0.65;
case 3: return 0.7;
case 4: return 0.8;
case 5: return 0.9;
case 6: return 0.95;
case 7: return 1;
}
}
};
}