From 593deae411421a81045336bc798966eb7d76e4d8 Mon Sep 17 00:00:00 2001 From: WilliamBishopCST116 <114703314+WilliamBishopCST116@users.noreply.github.com> Date: Mon, 28 Nov 2022 13:09:15 -0800 Subject: Add files via upload --- CST116-Lab3-Pseudocode- Bishop.txt | 77 ++++++++++++++++++++++++++++++++++++++ CST116-lab3-SubmitFinal-Bishop.cpp | 77 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 CST116-Lab3-Pseudocode- Bishop.txt create mode 100644 CST116-lab3-SubmitFinal-Bishop.cpp diff --git a/CST116-Lab3-Pseudocode- Bishop.txt b/CST116-Lab3-Pseudocode- Bishop.txt new file mode 100644 index 0000000..06ac5cb --- /dev/null +++ b/CST116-Lab3-Pseudocode- Bishop.txt @@ -0,0 +1,77 @@ +// 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 << 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 << 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; 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. + + + } +} diff --git a/CST116-lab3-SubmitFinal-Bishop.cpp b/CST116-lab3-SubmitFinal-Bishop.cpp new file mode 100644 index 0000000..7c3d1d5 --- /dev/null +++ b/CST116-lab3-SubmitFinal-Bishop.cpp @@ -0,0 +1,77 @@ +// 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 + +using namespace std; + +using std::cout; +using std::cin; +using std::endl; +int totals(int totalpeople) +int main() +{ + ofstream inFile; + inFile.open("smaltext.txt"); + cout << "What is the name of the file we have?"; + 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"; + 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 "; + in.close(); + } + + double totalfare1[4] = { 84, 15, 12, 13 }; + ofstream file_("totals.txt"); + inFile.open("totals.txt"); + if (file_.is_open()) { + file_ << totalfare1 << endl; + in.close(); + + } + std::cin.get(); + int totalpeople = 15; + cout << totalfare1 << endl; + int totals(int totalpeople); + 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; + +} +int totals(int totalpeople) +{ + double totalfare1[] = { 84, 15, 12, 13 }; + + totalpeople = 15; + cout << totalfare1 << endl; + int totalpaid = 0; + for (int i = 0; i < 4; i++) { + totalpaid = totalpaid + totalfare1[i]; + } + cout << totalpaid << endl; + float avgcostperperson; + avgcostperperson = totalpaid / totalpeople; + cout << avgcostperperson; + ofstream file_("totals.txt"); + inFile.open("totals.txt"); + if (file_.is_open()) { + file_ << totalfare1 << endl; + file_ << totalpaid << endl; + file_ << avgcostperperson << endl; + file_ << totalpeople << endl; + + + } +} -- cgit v1.2.3