Added Files from Local to Repo

Added Project 1/Homework 1 and Lab 1. Modified the Lab 2 folder to match conventions.
This commit is contained in:
Charles Descamps 2022-09-07 15:36:59 -07:00
parent dea1f746be
commit 7452a9ca4f
11 changed files with 2219 additions and 56 deletions

57
Lab02/Lab_2_Project.c Normal file
View file

@ -0,0 +1,57 @@
// 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();
}