Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-----------------------------------------------------------------------------
- //Exercise 3 Grading Block
- //Name:
- //Grade:
- //General Comments:
- //
- //Program Specifications
- // Precision set for floating point values
- // Constants created for program heading and name
- // Variables declared of the correct type, one per line
- // Original ounces assigned above each conversion to the correct
- // value placed in each section for each conversion
- // Calculate the correct number of gallons
- // Calculate the correct number of quarts
- // Calculate the correct number of cups
- // Calculate the remaining ounces
- // Output the heading lines centered on the screen using
- // the length function and setw to center the labels
- // Output the conversion number from the incremented variable
- // Output the conversion results aligned under the correct column
- // heading
- // Only one set of variables created for all the conversions
- // Totals for the original ounces & all calculated
- // values accumulated correctly
- // Totals output on one line with a label, aligned under the correct
- // column
- // Averages calculated,results stored in a double
- // Averages output on one line with a label, aligned under the correct
- // column displaying 3 decimal places
- // Divider used to block the output appropriately
- // created using setfill and setw
- //
- // Comment:
- //
- //
- // Points Lost ------------------------------------------------->
- //
- //-----------------------------------------------------------------------------
- // Total Possible Lab Grade ------------------------------------> 200
- // Total Points Lost ------------------------------------------->
- // Actual Lab Grade -------------------------------------------->
- //-----------------------------------------------------------------------------
- //contents of CSTStandardRequirements.txt
- //-----------------------------------------------------------------------------
- //Project
- // Project named correctly: YourLastNameFirstInitialExN
- // - where N is the assignment number
- // CSTStandardRequirements.txt attached to the project for EVERY lab
- // NO extra files attached to the solution
- // Automatic 0 grade for the exercise if any of these requirements are not met:
- // Project created correctly in a SINGLE directory for the solution
- // as specified in the instructions provided to create a VISUAL project
- // Compiles with 0 ERRORS & 0 WARNINGS
- // No run-time errors produced during execution of the program
- // Output produces correct results for all reasonable input
- //-----------------------------------------------------------------------------
- //
- //File Requirements (if input and/or output files are used in the program
- // Physical & Logical Files named correctly, according to lab specs
- // Input/Output files opened according to Exercise/Lab specs
- // Files closed at the end of the project
- // Input files contain the correct data
- // All input/output files are added to solution
- //-----------------------------------------------------------------------------
- //
- //Documentation
- // Grading Documentation Block for the lab copied and pasted at the
- // top of the cpp file
- // Name typed in appropriate line of grading block
- // Main Documentation Block included and correct
- // Input, Output, Process and program flow for each task/Problem discussed
- // accurately, clearly & completely. Spelling is correct.
- //-----------------------------------------------------------------------------
- //
- //Comments
- // Appropriately placed for pre-processor directives, constants, variables,
- // & in the code
- // Comments to block each task/problem as specified for the exercise/lab
- //-----------------------------------------------------------------------------
- //
- //Constants
- // Constants created in the correct location, named appropriately,
- // of the correct type, blocked by task#
- //-----------------------------------------------------------------------------
- //
- //Variables
- // Named appropriately - meaningful names to represent the task
- // Declared in correct location
- // Declared ONE variable per line
- // Variables are blocked by task then type
- // Declared of the correct datatype
- // Initialized in the code for the task not in the declaration statement
- // All variables needed created for the solution
- // Spelled correctly
- //-----------------------------------------------------------------------------
- //
- //Code
- // Completely viewable in Visual Studio Text Editor Window without scrolling
- // to the right (approximately 80 columns)
- // Spelling correct throughout the program
- // Indentation style of the course met as shown in the Program Specs
- // & Course Examples
- // Items in the correct order - grading block, documentation block,
- // pre-processor directives, function prototypes(if applicable),
- // constants, main function & variables
- // Body of Conditionals and loops in braces
- // even if the block contains one statement
- //-----------------------------------------------------------------------------
- //
- //Programmer's Name: Your name HERE
- //Program: Exercise
- //Description (IPO):
- //
- //
- //
- //
- //
- //
- //
- //-----------------------------------------------------------------------------
- //Preprocessor Directives
- #include <iostream>
- #include <iomanip>
- #include <string>
- //Namespace
- using namespace std;
- //Set Costansts
- const int original_oz2 = 149;
- const int original_oz3 = 5332;
- const int original_oz4 = 27326;
- const int original_oz1 = 3327;
- const int SCREEN_WIDTH = 79;
- const int DIVIDER_WIDTH = 79;
- //Name plate
- const string TITLE = "Exercise 3 - Liquid Measure Conversion";
- const string NAME = "Thomas Story";
- int main(void)
- {
- //Variable Declarations
- int gallons = 0;
- int quarts = 0;
- int cups = 0;
- int ounces = 0;
- int temp = original_oz1;
- int StringLength;
- int PrintWidth;
- //Output Title
- StringLength = TITLE.length();
- PrintWidth = (SCREEN_WIDTH + StringLength) / 2;
- cout << setw(PrintWidth) << TITLE << endl;
- //Output Name
- StringLength = NAME.length();
- PrintWidth = (SCREEN_WIDTH + StringLength) / 2;
- cout << setw(PrintWidth) << NAME << endl;
- //Output Divider
- cout << setfill('-') << setw(DIVIDER_WIDTH + 1) << " " << setfill(' ') << endl;
- //column Output
- cout << setw(10) << "Original Oz." << setw(10) << "Gallons" << setw(10) << "Quarts"
- << setw(10) << "Cups" << setw(10) << "Ounces" << endl;
- //-----------------First Conversion----------------------------------------
- gallons = original_oz1 / 128;
- // temp = temp - (gallons * 128);
- quarts = (original_oz1 % 128) / 32;
- // temp = temp - (quarts * 32);
- cups = (gallons % 32) / 8;
- // temp = temp - (cups * 8);
- ounces = original_oz1 - ((gallons * 128) + (quarts * 32) + (cups * 8));
- // ounces = temp;
- cout << setw(10) << original_oz1 << setw(10) << gallons << setw(10)
- << quarts << setw(10) << cups << setw(10) << ounces << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement