Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Using Namespace Int Int Int For Int For If If Else: #Include

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Ромб

#include <iostream>
using namespace std;

int main()
{
int a=9, b = 9;
int center = b / 2;
for (int i = 0; i < b; i++)
{
for (a = 0; a < b; a++)
{
if (i <= center)
{
if (a > center - i && a < center + i)
cout << "*";
else
cout << " ";
}
else
{
if (a > center + i - b + 1 && a < center - i + b - 1)
cout << "*";
else
cout << " ";
}
}
cout << endl;
}

1.Діапазон и число

#include <iostream>
using namespace std;
int main()
{
int a, b, number = 0;
cout << "Range ->";
cin >> a >> b;
cout << "Number ->";
cin >> number;
if (number <= b and number >= a) {
cout << "4islo naleshit diapazony" << endl;
}
while (number <a || number >b)
{
cout << "4islo ne naleshit diapazony; " << "Number ->";
cin >> number;
if (number <= b and number >= a) {
cout << "4islo naleshit diapazony" << endl;
}
}
}

2.Таблиця умножения
#include <iostream>
#include <time.h>
using namespace std;

int main()
{
srand(time(0));
while (true)
{
int level = 0;
cout << "Select the difficulty level:" << endl;
cout << "1.Easy \n2.Nornal \n3.Hard" << endl;
cin >> level;
switch (level)
{
case 1:
{
int count = 0;
while (count <= 5)
{
int a = rand() % 10 + 1;
int b = rand() % 10 + 1;
cout << a << " * " << b << " = " << endl;
int result = a * b;
int c = 0;
cin >> c;
if (result == c)
{
cout << "True" << endl;
}
else
{
cout << "NO! Result is: " << result << endl;
}
count++;
}
}
case 2:
{
int count = 0;
while (count <= 8)
{
int a = rand() % 10 + 1;
int b = rand() % 10 + 1;
int d = rand() % 10 + 1;
cout << a << " * " << b << " * " << d << " = " << endl;
int result = a * b * d;
int c = 0;
cin >> c;
if (result == c)
{
cout << "True!" << endl;
}
else
{
cout << "Error. Result is: " << result << endl;
}
count++;
}
}
case 3:
{
int count = 0;
while (count <= 11)
{
int a = rand() % 10 + 1;
int b = rand() % 10 + 1;
int d = rand() % 10 + 1;
int e = rand() % 10 + 1;
cout << a << " * " << b << " * " << d << " * " << e << " = "
<< endl;
int result = a * b * d * e;
int c = 0;
cin >> c;
if (result == c)
{
cout << "True!" << endl;
}
else
{
cout << "Error. Result is: " << result << endl;
}
count++;
}
}
}
}

Задание . Написать имитацию кассового аппарата


#include <iostream>
#include <string>
using namespace std;

int main()
{
float PayDesk = 0.0;
float CheckAmound = 0.0;
int SoftToyCount = 100, ChristmasToyCount = 100, ChristmasGarlendCount = 100,
ChristmasHatCount = 100, ChristmasOutfitCount = 100;
float const SoftToy = 13.5;
float const ChristmasToy = 10.1;
float const ChristmasGarlend = 15.6;
float const ChristmasHat = 8.4;
float const ChristmasOutfit = 26.8;

while (true)
{
cout << "Soft Toy -- Product code -- 1 -- " << SoftToy << "$" << endl;
cout << "Christmas Toy -- Product code -- 2 -- " << ChristmasToy << "$" <<
endl;
cout << "Christmas Garlend -- Product code -- 3 -- " << ChristmasGarlend <<
"$" << endl;
cout << "Christmas Hat -- Product code -- 4 -- " << ChristmasHat << "$" <<
endl;
cout << "Christmas Ofit -- Product code -- 5 -- " << ChristmasOutfit << "$"
<< endl;

int Product = -1;


CheckAmound = 0;
string basket = "";
while (Product != 0)
{
cout << "\nEnter the product code you want to purchase: " << endl;
cin >> Product;
switch (Product)
{
case 1:
{
int count = 0;
cout << "\nEnter the product count you want to purchase: ";
cin >> count;
if (count > 0 && count < SoftToyCount)
{
float totalCost = SoftToy * count;
CheckAmound += totalCost;
SoftToyCount = SoftToyCount - count;
basket = basket + "\n" + to_string(count) + " Soft
Toys";
cout << "\nSoft Toy added!";
}
else
{
cout << "Count less then zero or we dont have enough
products\n";
}
break;
}
case 2: {
int count = 0;
cout << "\nEnter the product count you want to purchase: ";
cin >> count;
if (count > 0 && count < ChristmasToyCount)
{
float totalCost = ChristmasToy * count;
CheckAmound += totalCost;
ChristmasToyCount = ChristmasToyCount - count;
basket = basket + "\n" + to_string(count) + " Christmas
Toys";
cout << "\nChristmas Toy added!";
}
else
{
cout << "Count less then zero or we dont have enough
products\n";
}
break;
}
case 3: {
int count = 0;
cout << "\nEnter the product count you want to purchase: ";
cin >> count;
if (count > 0 && count < ChristmasGarlendCount)
{
float totalCost = ChristmasGarlend * count;
CheckAmound += totalCost;
ChristmasGarlendCount = ChristmasGarlendCount - count;
basket = basket + "\n" + to_string(count) + " Christmas
Garlends";
cout << "\nChristmas Garlends added!";
}
else
{
cout << "Count less then zero or we dont have enough
products\n";
}
break;
}
case 4: {
int count = 0;
cout << "\nEnter the product count you want to purchase: ";
cin >> count;
if (count > 0 && count < ChristmasHatCount)
{
float totalCost = ChristmasHat * count;
CheckAmound += totalCost;
ChristmasHatCount = ChristmasHatCount - count;
basket = basket + "\n" + to_string(count) + " Christmas
Hats";
cout << "\nChristmas Hat added!";
}
else
{
cout << "Count less then zero or we dont have enough
products\n";
}
break;
}
case 5: {
int count = 0;
cout << "\nEnter the product count you want to purchase: ";
cin >> count;
if (count > 0 && count < ChristmasOutfitCount)
{
float totalCost = ChristmasOutfit * count;
CheckAmound += totalCost;
ChristmasOutfitCount = ChristmasOutfitCount - count;
basket = basket + "\n" + to_string(count) + " Christmas
Oufit";
cout << "\nChristmas Outfit added!";
}
else
{
cout << "Count less then zero or we dont have enough
products\n";
}
break;
}
}
}
cout << "Thanks for visit us!!!\n";
cout << "Your check is :" << basket;
if (CheckAmound > 100 && CheckAmound <= 200)
{
CheckAmound = CheckAmound - ((CheckAmound / 100) * 5);
cout << "\nYou have 5% discount";
}
else if (CheckAmound > 200 && CheckAmound <= 400)
{
CheckAmound = CheckAmound - ((CheckAmound / 100) * 10);
cout << "\nYou have 10% discount";
}
else if (CheckAmound > 400)
{
CheckAmound = CheckAmound - ((CheckAmound / 100) * 25);
cout << "\nYou have 25% discount";
}
PayDesk += CheckAmound;
cout << "\n Total prise is: " << CheckAmound << "\n\nStore proceeds now
is : " << PayDesk << "$\n\n\n\n";
}
}

You might also like