Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Raymond Ver
- Professor Pape
- raymond.c.ver@gmail.com
- CIS 22A
- 20 October 2015
- Lab 3 - Audio Visual Equipment
- */
- #include <iostream>
- #include <iomanip>
- #include <stdlib.h>
- #include <string>
- #include <cctype>
- using namespace std;
- #define newreqPercent 0.9
- #define oldreqPercent 0.65
- #define newSugPercent 0.4
- #define oldSugPercent 0.2
- #define profitRatePercent 0.8
- void signature()
- {
- string position, email, labNum;
- position = "Student :\t";
- email = "Email :\t";
- labNum = "Lab Number :\t";
- cout << position + "Raymond Ver\n";
- cout << email + "raymond.c.ver@gmail.com\n";
- cout << labNum + "4\n\n";
- }
- double calcBooks(char, char, int);
- double calcProfit( double, int);
- void printOutput(string, int, double);
- int main()
- {
- //Declaration of Variables
- string isbn;
- double pricePerCopy;
- double profit;
- int classNumber;
- int copiesNeeded;
- char reqOrSug;
- char newOrOld;
- //Asking user for input
- cout << "Enter book number (10 digits): ";
- cin >> isbn;
- cout << "Enter price per copy: ";
- cin >> pricePerCopy;
- cout << "Enter expected class enrollment:";
- cin >> classNumber;
- cout << "Enter 'R' if required or 'S' if suggested:";
- cin >> reqOrSug;
- reqOrSug = toupper(reqOrSug);
- cout << "Enter 'N' if new or 'O' if not a new text:";
- cin >> newOrOld;
- newOrOld = toupper(newOrOld);
- //Print the number of books to be ordered
- copiesNeeded = static_cast<int>(calcBooks(reqOrSug, newOrOld, classNumber) + .5);
- //Print out the profit of the store after paying 80%
- profit = calcProfit(pricePerCopy, copiesNeeded);
- //Print out the 3 outputs
- printOutput(isbn, copiesNeeded, profit);
- cout << endl;
- signature();
- system("pause");
- return 0;
- }
- //end main
- ////////////////////////////////////////////
- double calcBooks(char reqOrSug, char newOrOld, int classNumber)
- {
- double copiesNeeded;
- if (reqOrSug == 'R')
- {
- if (newOrOld == 'N')
- {
- copiesNeeded = newreqPercent * classNumber +.5;
- }
- else if (newOrOld == 'O')
- {
- copiesNeeded = oldreqPercent * classNumber;
- }
- else
- {
- cout << "\n\nError\n\n";
- system("pause");
- exit(42);
- }
- }
- else if (reqOrSug == 'S')
- {
- if (newOrOld == 'N')
- {
- copiesNeeded = newSugPercent * classNumber;
- }
- else if (newOrOld == 'O')
- {
- copiesNeeded = oldSugPercent * classNumber;
- }
- else
- {
- cout << "\n\nError\n\n";
- system("pause");
- exit(42);
- }
- }
- else
- {
- cout << "\n\nError\n\n";
- system("pause");
- exit (42);
- }
- return copiesNeeded;
- }
- double calcProfit(double pricePerCopy, int copiesNeeded)
- {
- double profit;
- profit = (pricePerCopy * copiesNeeded) - ((pricePerCopy * copiesNeeded) * profitRatePercent);
- return profit;
- }
- void printOutput(string isbn, int copiesNeeded, double profit)
- {
- cout << setprecision(2) << fixed;
- cout << endl;
- cout << endl;
- cout << "ISBN :\t" << isbn << endl;
- cout << "Copies Needed :\t" << copiesNeeded << endl;
- cout << "Profit :\t" << "$" << profit << endl;
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement