Done!
This commit is contained in:
parent
457473368c
commit
c2e6b6f97c
@ -1,35 +1,85 @@
|
||||
// Eisverkauf.cpp : Diese Datei enthält die Funktion "main". Hier beginnt und endet die Ausführung des Programms.
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void Greeting();
|
||||
|
||||
double GetPrice(int index);
|
||||
void greeting();
|
||||
double order(vector<const char*> persons, double available_money);
|
||||
void billing(double change, double available_money);
|
||||
double get_price(int index);
|
||||
|
||||
/**
|
||||
* \brief ice cream sale
|
||||
* \return zero if successful.
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
double
|
||||
Greeting();
|
||||
const auto persons = {"Freund 1", "Freund 2", "Du"};
|
||||
const auto available_money = 5.0;
|
||||
|
||||
greeting();
|
||||
const auto change = order(persons, available_money);
|
||||
billing(change, available_money);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Greeting()
|
||||
/**
|
||||
* \brief Writes a greeting message.
|
||||
*/
|
||||
void greeting()
|
||||
{
|
||||
cout << "Hallo!" << endl;
|
||||
cout << "Folgende Eissorten sind vorhanden:" << endl;
|
||||
cout << "1. Capri: 1,10 €" << endl;
|
||||
cout << "2. Nogger: 1,60 €" << endl;
|
||||
cout << "3. Cornetto : 2,30 €" << endl;
|
||||
|
||||
|
||||
cout << "1. Capri: 1,10 Euro" << endl;
|
||||
cout << "2. Nogger: 1,60 Euro" << endl;
|
||||
cout << "3. Cornetto : 2,30 Euro" << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Take an order and pay attention to the available money.
|
||||
* \param persons The people at the counter
|
||||
* \param available_money Available money
|
||||
* \return Remaining money.
|
||||
*/
|
||||
double order(vector<const char*> persons, double available_money)
|
||||
{
|
||||
for (auto person : persons)
|
||||
{
|
||||
cout << "Hallo " << person << "!" << endl;
|
||||
if (available_money < 1.1)
|
||||
{
|
||||
cout << "Sie koennen kein Eis mehr kaufen." << endl;
|
||||
break;
|
||||
}
|
||||
cout << "Bitte geben Sie ihre Bestellung auf (1-3): ";
|
||||
int input;
|
||||
cin >> input;
|
||||
available_money -= get_price(input);
|
||||
}
|
||||
return available_money;
|
||||
}
|
||||
|
||||
double GetPrice(int index)
|
||||
/**
|
||||
* \brief Creates the bill and returns the change
|
||||
* \param change The remaining money
|
||||
* \param available_money The payed money.
|
||||
*/
|
||||
void billing(const double change, const double available_money)
|
||||
{
|
||||
cout << endl;
|
||||
cout << "Zu zahlender Betrag: " << available_money - change << " Euro" << endl;
|
||||
cout << "Ihr Restgeld betraegt: " << change << " Euro" << endl;
|
||||
cout << endl;
|
||||
cout << "Danke, beehren sie uns bald wieder!";
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get prices of chosen product.
|
||||
* \param index of the product.
|
||||
* \return the price of the product.
|
||||
*/
|
||||
double get_price(const int index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
|
Loading…
x
Reference in New Issue
Block a user