Added Project 1/Homework 1 and Lab 1. Modified the Lab 2 folder to match conventions.
57 lines
No EOL
1.3 KiB
C
57 lines
No EOL
1.3 KiB
C
// This is lab2 for CS136L
|
|
// By Andrew Angus and Charles Descamps
|
|
|
|
// include files
|
|
#include "Console_IO_Utility.h"
|
|
#include "StandardConstants.h"
|
|
|
|
//global constants
|
|
// this constant is to adjust input to accomodate the 0.45 rounding
|
|
const double CHANGE_IN_DECIMAL = 0.55;
|
|
const int MULTIPLE_LINE_SPACES = 2;
|
|
const int LENGTH_OF_SEPERATOR = 16;
|
|
|
|
// main program
|
|
int main()
|
|
{
|
|
|
|
// initialize variables
|
|
double valueToRound;
|
|
|
|
// prints the intro
|
|
printEndline();
|
|
|
|
// need to print the title of the program.
|
|
printString("Rounding Program");
|
|
|
|
// prints another blank line
|
|
printEndline();
|
|
|
|
// also print a separator (16 equal signs)
|
|
printCharacters(LENGTH_OF_SEPERATOR, '=');
|
|
|
|
// another blank line
|
|
printEndlines(MULTIPLE_LINE_SPACES);
|
|
|
|
// Ask user for the value to round
|
|
valueToRound = promptForDouble("Enter a value to be rounded: ");
|
|
|
|
// Round the value by adding change in decimal, then round
|
|
valueToRound += CHANGE_IN_DECIMAL;
|
|
valueToRound = (int)valueToRound;
|
|
valueToRound = (double)valueToRound;
|
|
|
|
// print out the rounded value
|
|
printString("The rounded value is now: ");
|
|
printDouble(valueToRound, PRECISION);
|
|
|
|
// print another blank line
|
|
printEndlines(MULTIPLE_LINE_SPACES);
|
|
|
|
// Print "Program End"
|
|
printString("Program End");
|
|
|
|
// print another new line.
|
|
printEndline();
|
|
|
|
} |