Skip to content

Instantly share code, notes, and snippets.

@CSaratakij
Last active July 25, 2018 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CSaratakij/f1c4dae17f0711f1b208e57e5c736da2 to your computer and use it in GitHub Desktop.
Save CSaratakij/f1c4dae17f0711f1b208e57e5c736da2 to your computer and use it in GitHub Desktop.
Result
#include <iostream>
#include <string>
#include <vector>
#include <stdbool.h>
struct OrderInfo
{
int price = 0;
std::string customerName;
std::string typeLine;
std::string typeSoup;
std::string typeMeat;
std::string extra;
};
void Quest1()
{
int width = 0;
int length = 0;
int area = 0;
std::cout << "\nPlease enter width : ";
std::cin >> width;
std::cout << "\nPlease enter length : ";
std::cin >> length;
area = (length * width);
std::cout << "Area is " << area << std::endl;
}
void Quest2()
{
int radius = 0;
float area = 0.0f;
std::cout << "\nEnter radius: ";
std::cin >> radius;
area = 3.14f * (radius * radius);
std::cout << "Area is : " << area << std::endl;
}
void Quest3()
{
int totalCustomer = 0;
int price = 0;
bool isNeedExtra = false;
std::vector<OrderInfo> playerOrderInfo;
std::cout << "\nPlease enter total customer: ";
std::cin >> totalCustomer;
std::cout << "\nCustomer total cout : " << totalCustomer;
for (unsigned int i = 0; i < totalCustomer; i++) {
OrderInfo info;
std::cout << "\nPlease enter customer name : ";
std::cin >> info.customerName;
std::cout << "\nSelect your type of line: ";
std::cin >> info.typeLine;
std::cout << "\nSelect your type of soup: ";
std::cin >> info.typeSoup;
std::cout << "\nSelect your type of meat: ";
std::cin >> info.typeMeat;
std::cout << "\nSelect extra or not (0 (No) / 1 (Yes)): ";
std::cin >> isNeedExtra;
if (isNeedExtra) {
info.price = 40;
info.extra = "Yes";
} else {
info.price = 35;
info.extra = "No";
}
playerOrderInfo.push_back(info);
}
for (unsigned int i = 0; i < totalCustomer; i++) {
OrderInfo info = playerOrderInfo[i];
std::cout << "Customer Name : " << info.customerName << std::endl;
std::cout << "Type of line : " << info.typeLine << std::endl;
std::cout << "Type of soup : " << info.typeSoup << std::endl;
std::cout << "Type of meat : " << info.typeMeat << std::endl;
std::cout << "Total price : " << info.price << std::endl;
}
}
int main()
{
unsigned int questionNumber = 0;
while (true) {
std::cout << "Select the question number : ";
std::cin >> questionNumber;
switch (questionNumber) {
case 1:
Quest1();
std::cout << "\nThanks for using us!!\n";
break;
case 2:
Quest2();
std::cout << "\nThanks for using us!!\n";
break;
case 3:
Quest3();
std::cout << "\nThanks for using us!!\n";
break;
default:
std::cout << "There is no question at a select number\n";
break;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment