Skip to content

Instantly share code, notes, and snippets.

@rifqire
Last active February 10, 2018 14:09
Show Gist options
  • Save rifqire/90fc718fbce17d91cde55f6177d8ce3f to your computer and use it in GitHub Desktop.
Save rifqire/90fc718fbce17d91cde55f6177d8ce3f to your computer and use it in GitHub Desktop.
A simple motorbike dealer program, created with C++ by Rifqi Rachmanda Eryawan. A Structured Programming project.
// Rifqi Rachmanda Eryawan
// 001201700004
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main() {
int brand, price, ans;
char response;
char name[100];
srand(time(NULL));
do{
cout << "Welcome to Knuckles Bike Dealer!" << endl;
cout << "Input name: " << endl;
cin >> name;
cout << "\nOur motorbikes are the most expensive ones in the United States of 'Murica!" << endl;
cout << "Select motorcycle brand: " << endl;
cout << "1. Neiman Marcus Limited Edition Fighter (USD 16 000 000)" << endl;
cout << "2. 1949 E90 AJS Porcupine (USD 10 000 000)" << endl;
cout << "3. Ecosse ES1 Spirit (USD 6 000 000)" << endl;
cout << "4. Hildebrand & Wolfmuller Bike (USD 5 500 000)" << endl;
cout << "5. Gold BMS Nehmesis (USD 5 000 000)\n" << endl;
cout << "Which variant you will buy? " << endl;
cin >> brand;
cout << "\nYou will buy a ";
switch (brand) //statement for multiple decisions
{
case 1:
cout << "Neiman Marcus Limited Edition Fighter." << endl;
price = 16000000;
break;
case 2:
cout << "1949 E90 AJS Porcupine." << endl;
price = 10000000;
break;
case 3:
cout << "Ecosse ES1 Spirit." << endl;
price = 6000000;
break;
case 4:
cout << "Hildebrand & Wolfmuller Bike." << endl;
price = 5500000;
break;
case 5:
cout << "Gold BMS Nehmesis." << endl;
price = 5000000;
break;
default : //any input than the others
price = 0;
break;
}
cout << "Click N to print the receipt." << endl;
cin >> response;
}
while (response == 'y' || response == 'Y');
cout << "\n";
cout << "\t===============================================" << endl;
cout << "\t KNUCKLES BIKE DEALER" << endl;
cout << "\t===============================================" << endl;
cout << "\tBuyer: " << name << endl;
cout << "\tMotorbike: ";
switch (brand) //statement for multiple decisions
{
case 1:
cout << "Neiman Marcus Limited Edition Fighter" << endl;
price = 16000000;
break;
case 2:
cout << "1949 E90 AJS Porcupine" << endl;
price = 10000000;
break;
case 3:
cout << "Ecosse ES1 Spirit" << endl;
price = 6000000;
break;
case 4:
cout << "Hildebrand & Wolfmuller Bike" << endl;
price = 5500000;
break;
case 5:
cout << "Gold BMS Nehmesis" << endl;
price = 5000000;
break;
default : //any input than the others
price = 0;
break;
}
cout << "\tPrice: USD " << price << endl;
// current date/time based on current system
time_t now = time(0);
// convert now to string form
char* dt = ctime(&now);
cout << "\tDate of purchase: " << dt << endl;
cout << "\tYour license plate is will be B "<< (rand()%9000)+1000 << " CIT when" << endl << "\tyour motorbike has come to Jakarta." << endl;
cout << "\t===============================================" << endl;
cout << "\t THANK YOU FOR SHOPPING!" << endl;
cout << "\t===============================================" << endl;
cout << "\n";
cout << "\tType anything and press enter to quit" << endl;
cin >> ans;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment