1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include<iostream>
#include<string>
using namespace std;
void PrintInstructions();
void PrintBill(int numberOfeBooks, float discount, float subTotal);
double SubTotal( float price, float discount);
double CalculateDiscount(int numberOfeBooks, float discount, float price);
int main()
{
while(1)
{
int numberOfeBooks = 0;
float discount = 0.15;
float costPrice = 8.99;
PrintInstructions();
cin>>numberOfeBooks;
system("cls");
float totalDiscount = CalculateDiscount(numberOfeBooks, discount, costPrice);
float subTotal = SubTotal(costPrice, discount);
PrintBill(numberOfeBooks, totalDiscount, subTotal);
}
}
void PrintInstructions()
{
cout<<"Welcome to BandN book store!"<<endl<<"Please enter the number of E-books that you require and hit [ENTER]."<<endl<<"15% discount is being offered and the cost price for each E-book is 8.99"<<endl;
cout<<"Please enter the number of eBooks"<<endl;
}
void PrintBill(int numberOfeBooks, float discountAmount, float subTotal)
{
cout<<"The total amount payable is as following: "<<endl<<endl;
cout<<"----------------------------------"<<endl;
cout<<"No. of E-books: "<<numberOfeBooks<<endl;
cout<<"Total Discount: "<<discountAmount<<endl;
cout<<"Cost/E-book: "<<subTotal<<endl;
cout<<"Amount Payable: "<<numberOfeBooks*subTotal<<endl;
cout<<"----------------------------------"<<endl<<endl;
cout<<"Press [ENTER] to continue"<<endl;
getchar();
system("cls");
}
float SubTotal( float price, float discount)
{
return price-discount;
}
float CalculateDiscount(int numberOfeBooks, float discount, float price)
{
return (numberOfeBooks*price)*discount;
}
|