Поможем написать учебную работу
Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.
Если у вас возникли сложности с курсовой, контрольной, дипломной, рефератом, отчетом по практике, научно-исследовательской и любой другой работой - мы готовы помочь.
МІНІСТЕРСТВО АГРАРНОЇ ПОЛІТИКИ ТА ПРОДОВОЛЬСТВА УКРАЇНИ
ВСП ТАЛЬНІВСЬКИЙ БУДІВЕЛЬНО-ЕКОНОМІЧНИЙ КОЛЕДЖ
УМАНСЬКОГО НУС
Звіт
По виконанню практичної роботи № 2
З дисципліни “Інструментальні засоби візуального програмування”
Виконав:
Студент групи ПС-47
Мудрагель Євгеній
Перевірив:
Бойко С.В.
Тальне 2013
Тема: Програма кафе.
Мета: Засвоїти методику створення та використання програми кафе.
Розвязок програми :
1.
Лістинг програми:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
float summ;
int sum;
int sum1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TForm1::CheckBox1Click(TObject *Sender)
{
if (CheckBox1->Checked)
{
summ+= (StrToFloat(ComboBox1->Items->Strings[ComboBox1->ItemIndex]) *
StrToFloat(Edit1->Text));
ComboBox1->Enabled = false;
Edit1->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox1->Items->Strings[ComboBox1->ItemIndex]) *
StrToFloat(Edit1->Text));
ComboBox1->Enabled = true;
Edit1->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox2Click(TObject *Sender)
{
if (CheckBox2->Checked)
{
summ+= (StrToFloat(ComboBox2->Items->Strings[ComboBox2->ItemIndex]) *
StrToFloat(Edit2->Text));
ComboBox2->Enabled = false;
Edit2->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox2->Items->Strings[ComboBox2->ItemIndex]) *
StrToFloat(Edit2->Text));
ComboBox2->Enabled = true;
Edit2->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox3Click(TObject *Sender)
{
if (CheckBox3->Checked)
{
summ+= (StrToFloat(ComboBox3->Items->Strings[ComboBox3->ItemIndex]) *
StrToFloat(Edit3->Text));
ComboBox3->Enabled = false;
Edit3->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox3->Items->Strings[ComboBox3->ItemIndex]) *
StrToFloat(Edit3->Text));
ComboBox3->Enabled = true;
Edit3->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox4Click(TObject *Sender)
{
if (CheckBox4->Checked)
{
summ+= (StrToFloat(ComboBox4->Items->Strings[ComboBox4->ItemIndex]) *
StrToFloat(Edit4->Text));
ComboBox4->Enabled = false;
Edit4->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox4->Items->Strings[ComboBox4->ItemIndex]) *
StrToFloat(Edit4->Text));
ComboBox4->Enabled = true;
Edit4->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox5Click(TObject *Sender)
{
if (CheckBox5->Checked)
{
summ+= (StrToFloat(ComboBox5->Items->Strings[ComboBox5->ItemIndex]) *
StrToFloat(Edit5->Text));
ComboBox5->Enabled = false;
Edit5->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox5->Items->Strings[ComboBox5->ItemIndex]) *
StrToFloat(Edit5->Text));
ComboBox5->Enabled = true;
Edit5->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox6Click(TObject *Sender)
{
if (CheckBox6->Checked)
{
summ+= (StrToFloat(ComboBox6->Items->Strings[ComboBox6->ItemIndex]) *
StrToFloat(Edit6->Text));
ComboBox6->Enabled = false;
Edit6->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox6->Items->Strings[ComboBox6->ItemIndex]) *
StrToFloat(Edit6->Text));
ComboBox6->Enabled = true;
Edit6->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox7Click(TObject *Sender)
{
if (CheckBox7->Checked)
{
summ+= (StrToFloat(ComboBox7->Items->Strings[ComboBox7->ItemIndex]) *
StrToFloat(Edit7->Text));
ComboBox7->Enabled = false;
Edit7->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox7->Items->Strings[ComboBox7->ItemIndex]) *
StrToFloat(Edit7->Text));
ComboBox7->Enabled = true;
Edit7->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox8Click(TObject *Sender)
{
if (CheckBox8->Checked)
{
summ+= (StrToFloat(ComboBox8->Items->Strings[ComboBox8->ItemIndex]) *
StrToFloat(Edit8->Text));
ComboBox8->Enabled = false;
Edit8->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox8->Items->Strings[ComboBox8->ItemIndex]) *
StrToFloat(Edit8->Text));
ComboBox8->Enabled = true;
Edit8->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox9Click(TObject *Sender)
{
if (CheckBox9->Checked)
{
summ+= (StrToFloat(ComboBox9->Items->Strings[ComboBox9->ItemIndex]) *
StrToFloat(Edit9->Text));
ComboBox9->Enabled = false;
Edit9->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox9->Items->Strings[ComboBox9->ItemIndex]) *
StrToFloat(Edit9->Text));
ComboBox9->Enabled = true;
Edit9->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox10Click(TObject *Sender)
{
if (CheckBox10->Checked)
{
summ+= (StrToFloat(ComboBox10->Items->Strings[ComboBox10->ItemIndex]) *
StrToFloat(Edit10->Text));
ComboBox10->Enabled = false;
Edit10->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox10->Items->Strings[ComboBox10->ItemIndex]) *
StrToFloat(Edit10->Text));
ComboBox10->Enabled = true;
Edit10->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox11Click(TObject *Sender)
{
if (CheckBox11->Checked)
{
summ+= (StrToFloat(ComboBox11->Items->Strings[ComboBox11->ItemIndex]) *
StrToFloat(Edit11->Text));
ComboBox11->Enabled = false;
Edit11->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox11->Items->Strings[ComboBox11->ItemIndex]) *
StrToFloat(Edit11->Text));
ComboBox11->Enabled = true;
Edit11->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox12Click(TObject *Sender)
{
if (CheckBox12->Checked)
{
summ+= (StrToFloat(ComboBox12->Items->Strings[ComboBox12->ItemIndex]) *
StrToFloat(Edit12->Text));
ComboBox12->Enabled = false;
Edit12->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox12->Items->Strings[ComboBox12->ItemIndex]) *
StrToFloat(Edit12->Text));
ComboBox12->Enabled = true;
Edit12->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox13Click(TObject *Sender)
{
if (CheckBox13->Checked)
{
summ+= (StrToFloat(ComboBox13->Items->Strings[ComboBox13->ItemIndex]) *
StrToFloat(Edit13->Text));
ComboBox13->Enabled = false;
Edit13->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox13->Items->Strings[ComboBox13->ItemIndex]) *
StrToFloat(Edit13->Text));
ComboBox13->Enabled = true;
Edit13->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox14Click(TObject *Sender)
{
if (CheckBox14->Checked)
{
summ+= (StrToFloat(ComboBox14->Items->Strings[ComboBox14->ItemIndex]) *
StrToFloat(Edit14->Text));
ComboBox14->Enabled = false;
Edit14->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox14->Items->Strings[ComboBox14->ItemIndex]) *
StrToFloat(Edit14->Text));
ComboBox14->Enabled = true;
Edit14->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox15Click(TObject *Sender)
{
if (CheckBox15->Checked)
{
summ+= (StrToFloat(ComboBox15->Items->Strings[ComboBox15->ItemIndex]) *
StrToFloat(Edit15->Text));
ComboBox15->Enabled = false;
Edit15->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox15->Items->Strings[ComboBox15->ItemIndex]) *
StrToFloat(Edit15->Text));
ComboBox15->Enabled = true;
Edit15->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox16Click(TObject *Sender)
{
if (CheckBox16->Checked)
{
summ+= (StrToFloat(ComboBox16->Items->Strings[ComboBox16->ItemIndex]) *
StrToFloat(Edit16->Text));
ComboBox16->Enabled = false;
Edit16->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox16->Items->Strings[ComboBox16->ItemIndex]) *
StrToFloat(Edit16->Text));
ComboBox16->Enabled = true;
Edit16->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox17Click(TObject *Sender)
{
if (CheckBox17->Checked)
{
summ+= (StrToFloat(ComboBox17->Items->Strings[ComboBox17->ItemIndex]) *
StrToFloat(Edit17->Text));
ComboBox17->Enabled = false;
Edit17->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox17->Items->Strings[ComboBox17->ItemIndex]) *
StrToFloat(Edit17->Text));
ComboBox17->Enabled = true;
Edit17->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::CheckBox18Click(TObject *Sender)
{
if (CheckBox18->Checked)
{
summ+= (StrToFloat(ComboBox18->Items->Strings[ComboBox18->ItemIndex]) *
StrToFloat(Edit18->Text));
ComboBox18->Enabled = false;
Edit18->Enabled = false;
}
else
{
summ-= (StrToFloat(ComboBox18->Items->Strings[ComboBox18->ItemIndex]) *
StrToFloat(Edit18->Text));
ComboBox18->Enabled = true;
Edit18->Enabled = true;
}
Label2->Caption = FloatToStrF(summ, ffCurrency, 6, 2);
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (summ > 50 && summ < 100) {
summ = summ * 0.95;
ShowMessage("Вам надається скидка 5%.\n"
"Сума замовлення: " + FloatToStrF(summ, ffGeneral, 6, 2) +
" грн.");
}
if (summ > 100 && summ < 150) {
summ = summ * 0.90;
ShowMessage("Вам надається скидка 10%.\n"
"Сума замовлення: " + FloatToStrF(summ, ffGeneral, 6, 2) +
" грн.");
}
if (summ > 150 && summ > 50) {
summ = summ * 0.85;
ShowMessage("Вам надається скидка 15%.\n"
"Сума замовлення: " + FloatToStrF(summ, ffGeneral, 6, 2) +
" грн.");
}
if (Label2->Caption == "0 грн.") ShowMessage("Нічого не вибрано!");
else
if ((Label2->Caption != "0 грн.") && (summ < 50))
ShowMessage("Сума замовлення: " + FloatToStrF(summ, ffGeneral, 6, 2) + " грн.");
}
void __fastcall TForm1::Button2Click(TObject *Sender)
{
CheckBox1->Checked = false;
ComboBox1->ItemIndex = 0;
CheckBox2->Checked = false;
ComboBox2->ItemIndex = 0;
CheckBox3->Checked = false;
ComboBox3->ItemIndex = 0;
CheckBox4->Checked = false;
ComboBox4->ItemIndex = 0;
CheckBox5->Checked = false;
ComboBox5->ItemIndex = 0;
CheckBox6->Checked = false;
ComboBox6->ItemIndex = 0;
CheckBox7->Checked = false;
ComboBox7->ItemIndex = 0;
CheckBox8->Checked = false;
ComboBox8->ItemIndex = 0;
CheckBox9->Checked = false;
ComboBox9->ItemIndex = 0;
CheckBox10->Checked = false;
ComboBox10->ItemIndex = 0;
CheckBox11->Checked = false;
ComboBox11->ItemIndex = 0;
CheckBox12->Checked = false;
ComboBox12->ItemIndex = 0;
CheckBox13->Checked = false;
ComboBox13->ItemIndex = 0;
CheckBox14->Checked = false;
ComboBox14->ItemIndex = 0;
CheckBox15->Checked = false;
ComboBox15->ItemIndex = 0;
CheckBox16->Checked = false;
ComboBox16->ItemIndex = 0;
CheckBox17->Checked = false;
ComboBox17->ItemIndex = 0;
CheckBox18->Checked = false;
ComboBox18->ItemIndex = 0;
Label2->Caption = "0 грн.";
}
Висновок:
Під час виконання роботи я засвоїв методику створення та використання програми конвертор.