Skip to content

Instantly share code, notes, and snippets.

@rifqire
Created February 10, 2018 14:06
Show Gist options
  • Save rifqire/1129e7657553c95303b983546da93ab4 to your computer and use it in GitHub Desktop.
Save rifqire/1129e7657553c95303b983546da93ab4 to your computer and use it in GitHub Desktop.
A simple motorbike dealer program along with installments, 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; // type anything and press enter to quit
int subtotal, rate, installment, total, month, paymonth;
char response; // press N to checkout
char name[100];
srand(time(NULL));
do{
cout << "Welcome to KNUCKLES HEAVY BIKE DEALER!" << endl;
cout << "Input name: ";
cin >> name;
cout << "\nOur motorbikes are the most expensive ones in the United States of Uganda!" << endl;
cout << "Select motorbike 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;
break;
case 2:
cout << "1949 E90 AJS Porcupine." << endl;
break;
case 3:
cout << "Ecosse ES1 Spirit." << endl;
break;
case 4:
cout << "Hildebrand & Wolfmuller Bike." << endl;
break;
case 5:
cout << "Gold BMS Nehmesis." << endl;
break;
default: // any input than the others
break;
}
cout << "Insert number of months for installment: ";
cin >> month;
cout << "\nPress N to checkout." << endl;
cin >> response;
}
while (response == 'y' || response == 'Y'); // when you press Y the program won't work properly
cout << "\n";
cout << "\t================================================" << endl;
cout << "\t KNUCKLES HEAVY 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;
}
subtotal = price / month;
rate = subtotal * 0.1;
installment = subtotal + rate;
total = installment * month;
paymonth = total / month;
cout << "\tInitial price: USD " << price << endl;
cout << "\tInstallment: " << month << " month(s)" << endl;
cout << "\tRate: 10%" << endl;
cout << "\tFinal price: USD " << total << endl;
// current date/time based on current system
time_t now = time(0);
// convert now to string form
char* dt = ctime(&now);
cout << "\tCheckout date: " << dt << endl;
cout << "\tYou must pay USD " << paymonth << " for " << month << " month(s)." << endl;
cout << "\n\tYour license plate will be B "<< (rand()%9000)+1000 << " CIT when" << endl << "\tyour motorbike has come to Jakarta." << endl;
cout << "\t================================================" << endl;
cout << "\t MUCHAS GRACIAS!" << endl;
cout << "\t================================================" << endl;
cout << "\n";
cout << "\tType anything and press enter to quit" << endl;
cin >> ans; // type anything
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment