#include 0 #include #include #include using namespace std; class customer // custo

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

#include 0 #include #include #include using namespace std; class customer // custo

Post by answerhappygod »

#include <iostream>0#include<fstream>#include <conio.h>#include<iomanip>using namespace std;
class customer // customer class{public: char customername [30]; char carmodel; char carnumber [20]; char data;};
class rent : public customer // inhereted class from customer class{public: int days = 0, rentalfee = 0; // additional int vatiables defined
void data() { //int login(); //login(); cout << "\t\t\t\tPlease Enter your Name: "; //taking data from the user cin >> customername; cout << endl;
do { cout << "\t\t\t\tPlease Select a Car" << endl; //giving user a choice to select among three different models cout << "\t\t\t\tEnter 'A' for Tesla 20011." << endl; cout << "\t\t\t\tEnter 'B' for Hyundai 2015." << endl; cout << "\t\t\t\tEnter 'C' for Honda 2020." << endl; cout << endl; cout << "\t\t\t\tChoose a Car from the above options: "; cin >> carmodel; cout << endl; cout << "--------------------------------------------------------------------------" << endl; if (carmodel == 'A') { system("CLS");
cout << "You have choosed Tesla model 2011" << endl; ifstream myfileA("A.txt"); //displaying details of model A char str[200]; while (myfileA) { myfileA.getline(str, 200); if (myfileA) cout << str << endl; }
} if (carmodel == 'B') { system("CLS");
cout << "You have choosed Hyundai model 2015" << endl; ifstream myfileB("B.txt"); //displaying details of model B char str[200]; while (myfileB) { myfileB.getline(str, 200); if (myfileB) cout << str << endl;
}
} if (carmodel == 'C') { system("CLS");
cout << "You have choosed Honda model 2020" << endl; ifstream myfileC("C.txt"); //displaying details of model A char str[200]; while (myfileC) { myfileC.getline(str, 200); if (myfileC) cout << str << endl; }
} if (carmodel != 'A' && carmodel != 'B' && carmodel != 'C')
cout << "Invaild Car Model. Please try again!" << endl; } while (carmodel != 'A' && carmodel != 'B' && carmodel != 'C');
cout << "Please provide following information: " << endl; //getting data from user related to rental service cout << "Please select a Car No. : "; cin >> carnumber; cout << "Number of days you wish to rent the car : "; cin >> days; cout << endl; } void calculate() { // sleep(1); system("CLS"); cout << "Calculating rent. Please wait......" << endl; if (carmodel == 'A' || carmodel == 'a') rentalfee = days * 56; if (carmodel == 'B' || carmodel == 'b') rentalfee = days * 60; if (carmodel == 'C' || carmodel == 'c') rentalfee = days * 100; }
void showrent() { cout << "\n\t\t Car Rental - Customer Invoice " << endl; cout << "\t\t ///////////////////////////////////////////////////////////" << endl; cout << "\t\t | Invoice No. :" << "------------------|" << setw(10) << "#Cnb81353" << " |" << endl; cout << "\t\t | Customer Name:" << "-----------------|" << setw(10) << customername << " |" << endl; cout << "\t\t | Car Model :" << "--------------------|" << setw(10) << carmodel << " |" << endl; cout << "\t\t | Car No. :" << "----------------------|" << setw(10) << carnumber << " |" << endl; cout << "\t\t | Number of days :" << "---------------|" << setw(10) << days << " |" << endl; cout << "\t\t | Your Rental Amount is :" << "--------|" << setw(10) << rentalfee << " |" << endl; cout << "\t\t ________" << endl; cout << "\n"; cout << "\t\t | Total Rental Amount is :" << "-------|" << setw(10) << rentalfee << " |" << endl; cout << "\t\t ________" << endl; cout << "\t\t # This is a computer generated invoce and it does not" << endl; cout << "\t\t require an authorised signture #" << endl; cout << " " << endl; cout << "\t\t ///////////////////////////////////////////////////////////" << endl; cout << "\t\t You are advised to pay up the amount before due date." << endl; cout << "\t\t Otherwise penelty fee will be applied" << endl; cout << "\t\t ///////////////////////////////////////////////////////////" << endl; int f; system("PAUSE");
system("CLS");
ifstream inf("thanks.txt");
char str[300];
while (inf) { inf.getline(str, 300); if (inf) cout << str << endl; } inf.close(); }};
int main() { rent obj2; //object created for rent class and further member functions are called obj2.data(); obj2.calculate(); obj2.showrent();
return 0; //end of the program}change this code into inline assembly...
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply