Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.94 KB | None | 0 0
  1. //-----------------------------------------------------------------------------
  2. //Exercise 3 Grading Block
  3. //Name:
  4. //Grade:
  5. //General Comments:
  6. //
  7. //Program Specifications
  8. // Precision set for floating point values
  9. // Constants created for program heading and name
  10. // Variables declared of the correct type, one per line
  11. // Original ounces assigned above each conversion to the correct
  12. // value placed in each section for each conversion
  13. // Calculate the correct number of gallons
  14. // Calculate the correct number of quarts
  15. // Calculate the correct number of cups
  16. // Calculate the remaining ounces
  17. // Output the heading lines centered on the screen using
  18. // the length function and setw to center the labels
  19. // Output the conversion number from the incremented variable
  20. // Output the conversion results aligned under the correct column
  21. // heading
  22. // Only one set of variables created for all the conversions
  23. // Totals for the original ounces & all calculated
  24. // values accumulated correctly
  25. // Totals output on one line with a label, aligned under the correct
  26. // column
  27. // Averages calculated,results stored in a double
  28. // Averages output on one line with a label, aligned under the correct
  29. // column displaying 3 decimal places
  30. // Divider used to block the output appropriately
  31. // created using setfill and setw
  32. //
  33. // Comment:
  34. //
  35. //
  36. // Points Lost ------------------------------------------------->
  37. //
  38. //-----------------------------------------------------------------------------
  39. // Total Possible Lab Grade ------------------------------------> 200
  40. // Total Points Lost ------------------------------------------->
  41. // Actual Lab Grade -------------------------------------------->
  42. //-----------------------------------------------------------------------------
  43. //contents of CSTStandardRequirements.txt
  44. //-----------------------------------------------------------------------------
  45. //Project
  46. // Project named correctly: YourLastNameFirstInitialExN
  47. // - where N is the assignment number
  48. // CSTStandardRequirements.txt attached to the project for EVERY lab
  49. // NO extra files attached to the solution
  50. // Automatic 0 grade for the exercise if any of these requirements are not met:
  51. // Project created correctly in a SINGLE directory for the solution
  52. // as specified in the instructions provided to create a VISUAL project
  53. // Compiles with 0 ERRORS & 0 WARNINGS
  54. // No run-time errors produced during execution of the program
  55. // Output produces correct results for all reasonable input
  56. //-----------------------------------------------------------------------------
  57. //
  58. //File Requirements (if input and/or output files are used in the program
  59. // Physical & Logical Files named correctly, according to lab specs
  60. // Input/Output files opened according to Exercise/Lab specs
  61. // Files closed at the end of the project
  62. // Input files contain the correct data
  63. // All input/output files are added to solution
  64. //-----------------------------------------------------------------------------
  65. //
  66. //Documentation
  67. // Grading Documentation Block for the lab copied and pasted at the
  68. // top of the cpp file
  69. // Name typed in appropriate line of grading block
  70. // Main Documentation Block included and correct
  71. // Input, Output, Process and program flow for each task/Problem discussed
  72. // accurately, clearly & completely. Spelling is correct.
  73. //-----------------------------------------------------------------------------
  74. //
  75. //Comments
  76. // Appropriately placed for pre-processor directives, constants, variables,
  77. // & in the code
  78. // Comments to block each task/problem as specified for the exercise/lab
  79. //-----------------------------------------------------------------------------
  80. //
  81. //Constants
  82. // Constants created in the correct location, named appropriately,
  83. // of the correct type, blocked by task#
  84. //-----------------------------------------------------------------------------
  85. //
  86. //Variables
  87. // Named appropriately - meaningful names to represent the task
  88. // Declared in correct location
  89. // Declared ONE variable per line
  90. // Variables are blocked by task then type
  91. // Declared of the correct datatype
  92. // Initialized in the code for the task not in the declaration statement
  93. // All variables needed created for the solution
  94. // Spelled correctly
  95. //-----------------------------------------------------------------------------
  96. //
  97. //Code
  98. // Completely viewable in Visual Studio Text Editor Window without scrolling
  99. // to the right (approximately 80 columns)
  100. // Spelling correct throughout the program
  101. // Indentation style of the course met as shown in the Program Specs
  102. // & Course Examples
  103. // Items in the correct order - grading block, documentation block,
  104. // pre-processor directives, function prototypes(if applicable),
  105. // constants, main function & variables
  106. // Body of Conditionals and loops in braces
  107. // even if the block contains one statement
  108. //-----------------------------------------------------------------------------
  109. //
  110. //Programmer's Name: Your name HERE
  111. //Program: Exercise
  112. //Description (IPO):
  113. //
  114. //
  115. //
  116. //
  117. //
  118. //
  119. //
  120. //-----------------------------------------------------------------------------
  121.  
  122. //Preprocessor Directives
  123. #include <iostream>
  124. #include <iomanip>
  125. #include <string>
  126.  
  127. //Namespace
  128. using namespace std;
  129.  
  130. //Set Costansts
  131. const int original_oz2 = 149;
  132. const int original_oz3 = 5332;
  133. const int original_oz4 = 27326;
  134. const int original_oz1 = 3327;
  135.  
  136. const int SCREEN_WIDTH = 79;
  137. const int DIVIDER_WIDTH = 79;
  138. //Name plate
  139. const string TITLE = "Exercise 3 - Liquid Measure Conversion";
  140. const string NAME = "Thomas Story";
  141.  
  142. int main(void)
  143. {
  144. //Variable Declarations
  145. int gallons = 0;
  146. int quarts = 0;
  147. int cups = 0;
  148. int ounces = 0;
  149.  
  150. int temp = original_oz1;
  151.  
  152. int StringLength;
  153. int PrintWidth;
  154.  
  155. //Output Title
  156. StringLength = TITLE.length();
  157. PrintWidth = (SCREEN_WIDTH + StringLength) / 2;
  158. cout << setw(PrintWidth) << TITLE << endl;
  159.  
  160. //Output Name
  161. StringLength = NAME.length();
  162. PrintWidth = (SCREEN_WIDTH + StringLength) / 2;
  163. cout << setw(PrintWidth) << NAME << endl;
  164.  
  165. //Output Divider
  166. cout << setfill('-') << setw(DIVIDER_WIDTH + 1) << " " << setfill(' ') << endl;
  167.  
  168. //column Output
  169. cout << setw(10) << "Original Oz." << setw(10) << "Gallons" << setw(10) << "Quarts"
  170. << setw(10) << "Cups" << setw(10) << "Ounces" << endl;
  171.  
  172. //-----------------First Conversion----------------------------------------
  173. gallons = original_oz1 / 128;
  174. // temp = temp - (gallons * 128);
  175.  
  176. quarts = (original_oz1 % 128) / 32;
  177. // temp = temp - (quarts * 32);
  178.  
  179. cups = (gallons % 32) / 8;
  180. // temp = temp - (cups * 8);
  181.  
  182. ounces = original_oz1 - ((gallons * 128) + (quarts * 32) + (cups * 8));
  183. // ounces = temp;
  184.  
  185. cout << setw(10) << original_oz1 << setw(10) << gallons << setw(10)
  186. << quarts << setw(10) << cups << setw(10) << ounces << endl;
  187.  
  188.  
  189.  
  190. return 0;
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement