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
|
#include <iostream>
#include <iomanip>
using namespace std;
int calcBalance(int invStart, int copRecieved, int copSold);
void displayOutput(int idNum, int invStart, int copReceived, int copSold, int newBalance);
int main(void)
{
int idNum, invStart, copReceived, copSold, newBalance;
cout << "Please enter an ID number: ";
cin >> idNum;
cout << "What is the inventory balance at the beginning of the month? ";
cin >> invStart;
cout << "What is the number of copies recieved? ";
cin >> copReceived;
cout << "Number of copies sold? ";
cin >> copSold;
newBalance = calcBalance(invStart, copReceived, copSold);
displayOutput(idNum, invStart, copReceived, copSold, newBalance);
return 0;
}
int calcBalance(int invStart, int copRecieved, int copSold)
{
int newBalance;
newBalance = invStart + copRecieved - copSold;
return newBalance;
}
void displayOutput(int idNum, int invStart, int copReceived, int copSold, int newBalance)
{
cout << "\n********************" << endl;
cout << "*Book Ends: January*" << endl;
cout << "********************" << endl;
cout << "\nID# " << setw(20) << "Inventory Start" << setw(15) << "# recieved" << setw(10) << "# Sold" << setw(20) << "New Inventory" << endl;
cout << "\n" << idNum << setw(5) << " " << invStart << setw(17) << " " << copReceived << setw(12) << " " << copSold << setw(10) << " " << newBalance << endl;
return;
}
|