Додаток М.1 Лістинг програми для обчислень оплати роботи підприємством

 

#include <iostream>

#include <conio.h>

 

using namespace std;

 

void shortIfF() {

int l;

double y, x, p, d;

cout << "Vuberit tup robotu 1, 2, 3: ";

cin >> l;

x = 12;

if (l == 1)

{

y = 100 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.1;

d = y - p;

}

if (l == 2)

{

y = 150 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.15;

d = y - p;

}

if (l == 3)

{

y = 200 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.2;

d = y - p;

}

 

 

cout << "\nZarplata: " << y << "\n";

cout << "Podatok: " << p << "\n";

cout << "Suma: " << d << "\n";

 

}

 

void longIfF() {

int l;

double y, x, p, d;

cout << "Vuberit tup robotu 1, 2, 3: ";

cin >> l;

x = 12;

if (l == 1)

{

y = 100 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.1;

d = y - p;

}

else if (l == 2)

{

y = 150 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.15;

d = y - p;

}

else if (l == 3)

{

y = 200 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.2;

d = y - p;

}

 

 

cout << "\nZarplata: " << y << "\n";

cout << "Podatok: " << p << "\n";

cout << "Suma: " << d << "\n";

}

 

void switchF() {

int l;

double y, x, p, d;

cout << "Vuberit tup robotu 1, 2, 3: ";

cin >> l;

x = 12;

switch (l)

{

case 1:

y = 100 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.1;

d = y - p;

break;

case 2:

y = 150 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.15;

d = y - p;

break;

case 3:

y = 200 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.2;

d = y - p;

break;

}

 

 

cout << "\nZarplata: " << y << "\n";

cout << "Podatok: " << p << "\n";

cout << "Suma: " << d << "\n";

}

 

void gotoF() {

int l, b;

double y, x, p, d;

cout << "Vuberit tup robotu 1, 2, 3: ";

cin >> l;

x = 12;

if (l == 1)

goto A;

if (l == 2)

goto B;

if (l == 3)

goto C;

 

A:

{

y = 100 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.1;

d = y - p;

goto stop;

}

 

B:

{

y = 150 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.15;

d = y - p;

goto stop;

}

 

C:

{

y = 200 * fabs(abs(cos(x) / 2.7) + 9.1 * sin(1.2 * x + 1) + 50);

p = y*0.2;

d = y - p;

goto stop;

}

 

stop:

 

cout << "\nZarplata: " << y << "\n";

cout << "Podatok: " << p << "\n";

cout << "Suma: " << d << "\n";

}

 

int main() {

 

int s;

repeat:

cout << "Vuberit tup rozvjazky 1, 2, 3, 4: ";

cin >> s;

 

switch (s)

{

case 1:

longIfF();

break;

case 2:

shortIfF();

break;

case 3:

switchF();

break;

case 4:

gotoF();

break;

default:

cout << "Nepravulne chuslo!\n";

goto repeat;

break;

}

 

 

_getch();

return 0;

}

 

 


Додаток М.2 Результат виконання програми для обчислень оплати роботи підприємством

 


Додаток Н Програма з використанням операторів вибору

Ввести номер поїзда. Вивести назви пунктів відправлення та призначення.

Додаток Н.1 Лістинг програми з використанням операторів вибору

#include <iostream>

#include <conio.h>

 

using namespace std;

 

void first(int c) {

 

if (c == 1)

cout << "Lviv - Kyiv";

if (c == 2)

cout << "Lviv - Ternopil";

if (c == 3)

cout << "Lviv - Zolochiv";

if (c == 4)

cout << "Kyiv - Uzhorod";

if (c == 5)

cout << "Lviv - Odesa";

if (c == 6)

cout << "Kyiv - Odesa";

if (c == 7)

cout << "Zolochiv - Lviv";

}

 

void second(int c) {

 

switch (c) {

case 1:

cout << "Lviv - Kyiv";

break;

case 2:

cout << "Lviv - Ternopil";

break;

case 3:

cout << "Lviv - Zolochiv";

break;

case 4:

cout << "Kyiv - Uzhorod";

break;

case 5:

cout << "Lviv - Odesa";

break;

case 6:

cout << "Kyiv - Odesa";

break;

case 7:

cout << "Zolochiv - Lviv";

break;

}

}

 

int main() {

 

int train;

int m;

cout << "Vvedit '1' dlja if i '2' dlja stitch: ";

cin >> m;

cout << "Vvedit nomer poizda: ";

cin >> train;

m == 1 ? first(train) : second(train);

 

_getch();

return 0;

}