Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <string>
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- char ticketPrice1[80], numberOfTicketsSold1[80];
- float totalTicketsSold = 0, totalSaleAmount = 0;
- ifstream file;
- file.open("ticketPrice.txt");
- ifstream file1;
- file1.open("numberofTicketsSold.txt");
- if(!file.is_open() && !file1.is_open()){
- cout << "File does not exist." << endl;
- }
- else {
- /*string ticketPrice;
- while(file.good())
- {
- getline(file,ticketPrice);
- cout << ticketPrice << endl;
- }*/
- while (file.eof()==0 && file1.eof()==0)
- {
- // File
- file.getline(ticketPrice1, sizeof(ticketPrice1));
- file1.getline(numberOfTicketsSold1, sizeof(numberOfTicketsSold1));
- // Test
- // cout << ticketPrice1 << "\t" << numberOfTicketsSold1 << endl;
- // Char to Float
- float ticketPrice = atof(ticketPrice1);
- float numberOfTicketsSold = atof(numberOfTicketsSold1);
- // Total
- // cout << setprecision(2) << fixed << showpoint << ticketPrice * numberOfTicketsSold << endl;
- float sales;
- sales = ticketPrice * numberOfTicketsSold;
- char sales1[80] = (char)sales;
- ofstream file3;
- file3.open("sales1.txt");
- file3 << sales1 << endl;
- ifstream file4;
- file4.open("sales1.txt")
- float totalTicketsSold;
- totalTicketsSold = atof(sales1)
- //cout << setprecision(2) << fixed << showpoint << sales << endl;
- //totalTicketsSold = 0;
- //cout << "Total Number of Tickets Sold: " << totalTicketsSold << endl;
- //cout << "Total Sale Amount: " << totalSaleAmount << endl;
- ;
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment