Advertisement
Guest User

ddddddd

a guest
Apr 23rd, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1.  
  2. /*
  3. * File: LAB08RM.cpp
  4. * Author: Richard Montes
  5. * Due: April 24 2014
  6. * Description: I work for a golf course that wants me to determine
  7. * distance from a cup from several predetermined locations
  8. * using coordinate data.
  9. * Created on April 22, 2014, 8:07 AM
  10. */
  11.  
  12. #include <fstream>
  13. #include <iostream>
  14. #include <iomanip>
  15. #include <cstring>
  16. #include <cmath>
  17. using namespace std;
  18.  
  19.  
  20.  
  21. void get_course_info_from_golfer(char [80]);
  22. void get_course_values_from_golfer
  23. (ifstream &, char [80], char [80], char [80], char [80], char [80], char [80]);
  24. void disp_rpt_hdr_to_golfer(ofstream &, char [80], char [80],
  25. char [80]);
  26.  
  27. void get_starting_positions(char [80]);
  28. void get_starting_posistion_values(ifstream &, char [80], int &, int &, int &);
  29. void process_each_location
  30. (ofstream &, char [80], int );
  31.  
  32. void disp_rpt_to_golfer(ofstream &, char [80], int , int , int );
  33.  
  34.  
  35. int main(void)
  36. {
  37. ifstream course_data, Starting_Positions_RM;
  38. ofstream course_data_file;
  39. char input_file_name[80], course_name[80], golfer_name[80], date_time[80],
  40. position_place[80], greens_keeper_name[80], report_file_name[80],
  41. position[80];
  42. int x_coord, y_coord, putt_speed, position_num;
  43.  
  44.  
  45. get_course_info_from_golfer(input_file_name);
  46. course_data.open(input_file_name);
  47. get_course_values_from_golfer
  48. (course_data, course_name, golfer_name, date_time, position_place,
  49. greens_keeper_name, report_file_name);
  50. disp_rpt_hdr_to_golfer(course_data_file, course_name, golfer_name,
  51. date_time);
  52. course_data.close();
  53.  
  54.  
  55. get_starting_positions(input_file_name);
  56.  
  57.  
  58. position_num = 8;
  59.  
  60. process_each_location
  61. (course_data_file, input_file_name, position_num);
  62.  
  63.  
  64.  
  65.  
  66. return 0;
  67. }
  68.  
  69. void get_course_info_from_golfer(char file_name[80])
  70. {
  71. cout << "Please enter Course Info file name; ";
  72. cin >> file_name;
  73. }
  74.  
  75. void get_course_values_from_golfer
  76. (ifstream &course_data, char course_name[80], char golfer_name[80],
  77. char date_time[80], char position_place[80],
  78. char greens_keeper_name[80], char report_file_name[80])
  79. {
  80. course_data >> course_name >> golfer_name >> date_time >> position_place
  81. >> greens_keeper_name >> report_file_name;
  82. }
  83.  
  84. void disp_rpt_hdr_to_golfer
  85. (ofstream &course_data_file, char course_name[80], char golfer_name[80],
  86. char date_time[80])
  87. {
  88. course_data_file.open("course_printout.txt");
  89. course_data_file << setprecision(1) << fixed;
  90. course_data_file << course_name << endl;
  91. course_data_file << "Home of The Holes In One!" << endl;
  92. course_data_file << "Golfer's Name: " << golfer_name << endl;
  93. course_data_file << "Date: " << date_time << endl <<endl;
  94. course_data_file << left << setw(19) << "Starting Position" << right
  95. << setw(10) << "Distance" << setw(10) <<
  96. "Putt Time" << endl;
  97.  
  98. }
  99.  
  100. void get_starting_positions(char file_name[80])
  101. {
  102. cout << "Please enter Starting Positions file; ";
  103. cin >> file_name;
  104. }
  105.  
  106. void get_starting_posistion_values
  107. (ifstream &Starting_Positions_RM, char position[80], int &x_coord,
  108. int &y_coord, int &putt_speed)
  109. {
  110. Starting_Positions_RM >> position >> x_coord >> y_coord >> putt_speed;
  111. }
  112.  
  113. void process_each_location
  114. (ofstream &course_data_file, char input_file_name[80], int position_num)
  115. {
  116. ifstream Starting_Positions_RM;
  117. double distance, putt_time;
  118. int count, x_coord, y_coord, putt_speed;
  119. char position[80];
  120.  
  121. Starting_Positions_RM.open(input_file_name);
  122.  
  123. count = 0;
  124.  
  125. while(count < position_num)
  126. {
  127. get_starting_posistion_values(Starting_Positions_RM, position,
  128. x_coord, y_coord, putt_speed);
  129. disp_rpt_to_golfer(course_data_file, position, x_coord, y_coord,
  130. putt_speed);
  131. count++;
  132. }
  133. Starting_Positions_RM.close();
  134. }
  135.  
  136. void disp_rpt_to_golfer
  137. (ofstream &course_data_file, char position[80], int x_coord,
  138. int y_coord, int putt_speed)
  139. {
  140.  
  141. course_data_file << setprecision(1) << fixed;
  142. course_data_file << position << endl;
  143. course_data_file << x_coord << endl;
  144. course_data_file << y_coord << endl;
  145. course_data_file << putt_speed << endl;
  146. course_data_file.close();
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement