Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <iomanip>
- using namespace std;
- void main()
- {
- //declare variables
- float boxPrice, sidePrice, genPrice,boxTotal,sideTotal,genTotal,Total;
- int boxSale,sideSale,genSale;
- fstream ticketSales;
- //open the file
- ticketSales.open("ticketSales.txt");
- //Get input form the file
- ticketSales >> boxPrice;
- ticketSales >> boxSale;
- ticketSales >> sidePrice;
- ticketSales >> sideSale;
- ticketSales >> genPrice;
- ticketSales >> genSale;
- //calculate totals
- boxTotal = (boxPrice*boxSale);
- sideTotal = (sidePrice*sideSale);
- genTotal = (genPrice*genSale);
- Total = (boxTotal+sideTotal+genTotal);
- //output (Holly cow batman! that's a lot of formatting!)
- cout << right << "Type:"<< setw(18) << "Price Each:" << setw(12) << "Sold:" << setw(15) << "Total:"<< setw(15);
- cout << right << "\nBox" << setw(19) << showpoint << setprecision(5) << boxPrice << setw(12) << boxSale << setw(15) << setprecision(9) << showpoint << boxTotal<< setw(15);
- cout << right << "\nSideline" << setw(14) << showpoint << setprecision(5) << sidePrice << setw(12) << sideSale << setw(15) << setprecision(9) << sideTotal<< setw(15);
- cout << right << "\nGen Adm" << setw(15) << showpoint << setprecision(4) << genPrice << setw(12) << genSale << setw(15) << setprecision(8) << genTotal<< setw(15);
- cout << "\n-------------------------------------------------";
- cout << setw(15) << "\nTotal:" << setw(43) << setprecision(9) << Total;
- //close the file
- ticketSales.close();
- //keep window up untill user hits enter
- cin.ignore();
- cin.get();
- }
Add Comment
Please, Sign In to add comment