Guest User

Untitled

a guest
Jan 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. void main()
  10. {
  11.     //declare variables
  12.     float boxPrice, sidePrice, genPrice,boxTotal,sideTotal,genTotal,Total;
  13.     int boxSale,sideSale,genSale;
  14.     fstream ticketSales;
  15.  
  16.     //open the file
  17.     ticketSales.open("ticketSales.txt");
  18.  
  19.     //Get input form the file
  20.     ticketSales >> boxPrice;
  21.     ticketSales >> boxSale;
  22.     ticketSales >> sidePrice;
  23.     ticketSales >> sideSale;
  24.     ticketSales >> genPrice;
  25.     ticketSales >> genSale;
  26.  
  27.     //calculate totals
  28.     boxTotal = (boxPrice*boxSale);
  29.     sideTotal = (sidePrice*sideSale);
  30.     genTotal = (genPrice*genSale);
  31.     Total = (boxTotal+sideTotal+genTotal);
  32.  
  33.     //output (Holly cow batman! that's a lot of formatting!)
  34.     cout << right << "Type:"<< setw(18) << "Price Each:" << setw(12) << "Sold:" << setw(15) << "Total:"<< setw(15);
  35.     cout << right << "\nBox" << setw(19) << showpoint << setprecision(5) << boxPrice << setw(12) << boxSale << setw(15) << setprecision(9) << showpoint << boxTotal<< setw(15);
  36.     cout << right << "\nSideline" << setw(14) << showpoint << setprecision(5) << sidePrice << setw(12) << sideSale << setw(15) << setprecision(9) << sideTotal<< setw(15);
  37.     cout << right << "\nGen Adm" << setw(15) << showpoint << setprecision(4) << genPrice << setw(12) << genSale << setw(15) << setprecision(8) << genTotal<< setw(15);
  38.     cout << "\n-------------------------------------------------";
  39.     cout << setw(15) << "\nTotal:" << setw(43) << setprecision(9) << Total;
  40.  
  41.     //close the file
  42.     ticketSales.close();
  43.  
  44.     //keep window up untill user hits enter
  45.     cin.ignore();
  46.     cin.get();
  47. }
Add Comment
Please, Sign In to add comment