Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: LAB08RM.cpp
- * Author: Richard Montes
- * Due: April 24 2014
- * Description: I work for a golf course that wants me to determine
- * distance from a cup from several predetermined locations
- * using coordinate data.
- * Created on April 22, 2014, 8:07 AM
- */
- #include <fstream>
- #include <iostream>
- #include <iomanip>
- #include <cstring>
- #include <cmath>
- using namespace std;
- void get_course_info_from_golfer(char [80]);
- void get_course_values_from_golfer
- (ifstream &, char [80], char [80], char [80], char [80], char [80], char [80]);
- void disp_rpt_hdr_to_golfer(ofstream &, char [80], char [80],
- char [80]);
- void get_starting_positions(char [80]);
- void get_starting_posistion_values(ifstream &, char [80], int &, int &, int &);
- void process_each_location
- (ofstream &, char [80], int );
- void disp_rpt_to_golfer(ofstream &, char [80], int , int , int );
- int main(void)
- {
- ifstream course_data, Starting_Positions_RM;
- ofstream course_data_file;
- char input_file_name[80], course_name[80], golfer_name[80], date_time[80],
- position_place[80], greens_keeper_name[80], report_file_name[80],
- position[80];
- int x_coord, y_coord, putt_speed, position_num;
- get_course_info_from_golfer(input_file_name);
- course_data.open(input_file_name);
- get_course_values_from_golfer
- (course_data, course_name, golfer_name, date_time, position_place,
- greens_keeper_name, report_file_name);
- disp_rpt_hdr_to_golfer(course_data_file, course_name, golfer_name,
- date_time);
- course_data.close();
- get_starting_positions(input_file_name);
- position_num = 8;
- process_each_location
- (course_data_file, input_file_name, position_num);
- return 0;
- }
- void get_course_info_from_golfer(char file_name[80])
- {
- cout << "Please enter Course Info file name; ";
- cin >> file_name;
- }
- void get_course_values_from_golfer
- (ifstream &course_data, char course_name[80], char golfer_name[80],
- char date_time[80], char position_place[80],
- char greens_keeper_name[80], char report_file_name[80])
- {
- course_data >> course_name >> golfer_name >> date_time >> position_place
- >> greens_keeper_name >> report_file_name;
- }
- void disp_rpt_hdr_to_golfer
- (ofstream &course_data_file, char course_name[80], char golfer_name[80],
- char date_time[80])
- {
- course_data_file.open("course_printout.txt");
- course_data_file << setprecision(1) << fixed;
- course_data_file << course_name << endl;
- course_data_file << "Home of The Holes In One!" << endl;
- course_data_file << "Golfer's Name: " << golfer_name << endl;
- course_data_file << "Date: " << date_time << endl <<endl;
- course_data_file << left << setw(19) << "Starting Position" << right
- << setw(10) << "Distance" << setw(10) <<
- "Putt Time" << endl;
- }
- void get_starting_positions(char file_name[80])
- {
- cout << "Please enter Starting Positions file; ";
- cin >> file_name;
- }
- void get_starting_posistion_values
- (ifstream &Starting_Positions_RM, char position[80], int &x_coord,
- int &y_coord, int &putt_speed)
- {
- Starting_Positions_RM >> position >> x_coord >> y_coord >> putt_speed;
- }
- void process_each_location
- (ofstream &course_data_file, char input_file_name[80], int position_num)
- {
- ifstream Starting_Positions_RM;
- double distance, putt_time;
- int count, x_coord, y_coord, putt_speed;
- char position[80];
- Starting_Positions_RM.open(input_file_name);
- count = 0;
- while(count < position_num)
- {
- get_starting_posistion_values(Starting_Positions_RM, position,
- x_coord, y_coord, putt_speed);
- disp_rpt_to_golfer(course_data_file, position, x_coord, y_coord,
- putt_speed);
- count++;
- }
- Starting_Positions_RM.close();
- }
- void disp_rpt_to_golfer
- (ofstream &course_data_file, char position[80], int x_coord,
- int y_coord, int putt_speed)
- {
- course_data_file << setprecision(1) << fixed;
- course_data_file << position << endl;
- course_data_file << x_coord << endl;
- course_data_file << y_coord << endl;
- course_data_file << putt_speed << endl;
- course_data_file.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement