// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there. // //William Bishop //william.bishop@oit.edu #include #include #include #include #include Here we have the pre-compiler directives to help compute the program using namespace std; using std::cout; using std::cin; using std::endl; int totals(int totalpeople) Here we declare our function int main() { ofstream inFile; inFile.open("smaltext.txt"); cout << "What is the name of the file we have?"; Here we open the file of smaltext and ask for the name of a file and get the taxilogic file. ofstream file_("taxilogic.txt"); inFile.open("taxilogic.txt"); if (file_.is_open()) { file_ << "total fare = fare+toll \n"; file_ << "Cost Per Mile = fare / distance\n"; file_ << " Toll 1, 2, 3, 4 are: 4, 5, 7, 8. \n"; We have the total toll and the fares in the program inside of our file is open file. file_ << " Fare 1, 2, 3, 4 are: 80, 15, 12, 13. \n"; file_ << " Total Fare 1, 2, 3, 4 are: 84, 20, 19, 21 \n"; file_ << "Mile rates are 15, 50, 40, 14, \n"; file_ << " So the Cost per miles are: 5.333,.3,.3, .928 \n "; Here we have opened the taxi logic file and kept printing in it. in.close(); We close the file } double totalfare1[4] = { 84, 15, 12, 13 }; Here we have the total fare array ofstream file_("totals.txt"); inFile.open("totals.txt"); if (file_.is_open()) { file_ << totalfare1 << endl; Here we have the opening and printing into the totals file. We print the total fare into it. in.close(); } std::cin.get(); cout << totalfare1 << endl; Here we have the output to the screen of the total fares array int totalpeople = 15; int totals(int totalpeople); Here we have our function that we have and a value that we have is passed into it. cout << "total fare = fare+toll , Cost Per Mile = fare / distance" << endl; cout << "Toll 1, 2, 3, 4 are: 4, 5, 7, 8. Fare 1, 2, 3, 4 are: 80, 15, 12, 13. " << endl; cout << "Mile rates are 15, 50, 40, 14, So the Cost per miles are: 5.333,.3,.3, .928 " << endl; Here we print out more information about the to the screen. } int totals(int totalpeople) Here we have our function that we have with the information passed in. { double totalfare1[] = { 84, 15, 12, 13 }; Here we have the array again of total fares totalpeople = 15; cout << totalfare1 <<"is total fares"<< endl; Here we print out the arrary of total fares int totalpaid = 0; for (int i = 0; i < 4; i++) { totalpaid = totalpaid + totalfare1[i]; Here we loop around the array and get the total paid variable. } cout << totalpaid <<"is total paid"<< endl; float avgcostperperson; avgcostperperson = totalpaid / totalpeople; Here we are printing out the variables of total cost and paid and the total fares to the screen cout << avgcostperperson<<"is average cost per person."; Here we are printing out the rest of our information ofstream file_("totals.txt"); inFile.open("totals.txt"); if (file_.is_open()) { file_ << totalfare1 << endl; file_ << totalpaid << endl; file_ << avgcostperperson << endl; file_ << totalpeople << endl; Here we opened our totals files and printed some more information into it. } }