diff options
| author | Jordan HarrisToovy <[email protected]> | 2021-10-10 18:31:11 -0700 |
|---|---|---|
| committer | Jordan HarrisToovy <[email protected]> | 2021-10-10 18:31:11 -0700 |
| commit | 1dbe334ebc840b23986388ddffc6cd827dee05e1 (patch) | |
| tree | 7dcc68ce66d2ad02a73fc03a21a73a03b3dd04a1 | |
| parent | Intermediate commit to save work (diff) | |
| download | cst116-lab2-jordanht-oit-1dbe334ebc840b23986388ddffc6cd827dee05e1.tar.xz cst116-lab2-jordanht-oit-1dbe334ebc840b23986388ddffc6cd827dee05e1.zip | |
| -rw-r--r-- | CST116F2021-Lab2/CST116F2021-Lab2.cpp | 187 | ||||
| -rw-r--r-- | CST116F2021-Lab2/Lab2-Console_output.txt (renamed from Lab2Harris-Toovy/Lab2 console output Harris-Toovy.txt) | 39 | ||||
| -rw-r--r-- | CST116F2021-Lab2/Lab2-Textual_work.txt (renamed from Lab2Harris-Toovy/Lab2 Textual work Harris-Toovy.txt) | 3 | ||||
| -rw-r--r-- | Lab2Harris-Toovy/Lab2Harris-Toovy.cpp | 100 | ||||
| -rw-r--r-- | Lab2Harris-Toovy/Lab2Harris-Toovy.vcxproj | 147 | ||||
| -rw-r--r-- | Lab2Harris-Toovy/Lab2Harris-Toovy.vcxproj.filters | 22 |
6 files changed, 214 insertions, 284 deletions
diff --git a/CST116F2021-Lab2/CST116F2021-Lab2.cpp b/CST116F2021-Lab2/CST116F2021-Lab2.cpp index 097604e..639232d 100644 --- a/CST116F2021-Lab2/CST116F2021-Lab2.cpp +++ b/CST116F2021-Lab2/CST116F2021-Lab2.cpp @@ -1,20 +1,183 @@ -// CST116F2021-Lab2.cpp : This file contains the 'main' function. Program execution begins and ends there. -// +//Code by Jordan Harris-Toovy for OIT'S CST116-01P Lab 2 - October 2021 +//Un-comment blocks for each assignment (re-comment when finished) #include <iostream> +#include <iomanip> + +//PART 3c - 4.13#2: +/* +using std::cout; + +int main() +{ + char ascii = 67; + cout << ascii << '\n'; + ascii = 43; + cout << ascii << '\n'; + cout << ascii << '\n'; + + return 0; +} +*/ + +//PART 3c - 4.13#3: +/* +using std::cout; + +int main() +{ + int myAgeYears = 24; + int myAgeDays; + const int yearDays = 365; + + myAgeDays = myAgeYears * yearDays; + + cout << "I am " << myAgeDays << " Days old."; + + return 0; +} +*/ + +//PART 4a - 5.4#1: +/* +using std::cout; +using std::cin; int main() { - std::cout << "Hello World!\n"; + float body_temp; + cout << "Enter you body temperature: "; + cin >> body_temp; + + cout.setf(std::ios::fixed); + cout.width(6); + cout << std::setprecision(1) << body_temp; + + return 0; } +*/ + +//PART 4a - 5.4#2: +/* +using std::cout; +using std::cin; +using std::setw; +using std::endl; + +int main() +{ + const int padding1 = 15; + const int padding2 = 30; + + cout.setf(std::ios::fixed); + cout.setf(std::ios::left); + + + cout << setw(padding1) << "First Name" << setw(padding1 - 5) << "GPA" << setw(padding1) << "Class" << setw(padding2) + << "Major" << setw(padding1) << "Credits" << endl; + + cout << setw(padding1) << "Bob" << setw(padding1 - 5) << std::setprecision(2) << 3.23 << setw(padding1) << "Freshman" << setw(padding2) + << "Software Engineering" << setw(padding1) << std::setprecision(0) << 23 << endl; + + cout << setw(padding1) << "Jamie" << setw(padding1 - 5) << std::setprecision(2) << 0.98 << setw(padding1) << "Freshman" << setw(padding2) + << "Underwater Basket" << setw(padding1) << std::setprecision(0) << 15 << endl; + + cout << setw(padding1) << "Marcus" << setw(padding1 - 5) << std::setprecision(2) << 4.00 << setw(padding1) << "Freshman" << setw(padding2) + << "Management" << setw(padding1) << std::setprecision(0) << 3 << endl; + + cout << setw(padding1) << "Phong" << setw(padding1 - 5) << std::setprecision(2) << 3.75 << setw(padding1) << "Junior" << setw(padding2) + << "Encryption" << setw(padding1) << std::setprecision(0) <<101 << endl; -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu + cout << setw(padding1) << "Webster" << setw(padding1 - 5) << std::setprecision(2) << 2.00 << setw(padding1) << "Sophomore" << setw(padding2) + << "Wildlife Management" << setw(padding1) << std::setprecision(0) << 56 << endl; -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file + return 0; +} + +*/ + +//PART 4b - 5.9: +/* +//Modified code from Chapter 5 Debug.cpp + +using std::cout; +using std::cin; +using std::endl; + +int main() +{ + float money = 123.45F; + float raise = 100.00F; //Set to 100 to avoid unexpected behavior + + cout << "You have $"; + cout << money << endl; + + // Breakpoint 1 + // Put a breakpoint on the following line (done) + cout << "Enter percent raise: "; + cin >> raise; + + money = money * (1.00F + (raise / 100.00F)); //Divide by 100 and add result to 1 to make it percent raise + + cout << "After your raise you have $"; + cout << money << endl; + + return 0; +} +*/ + +//PART 4b - 5.10: +/* +//Modified code from PE 5_1.cpp +//Fixed header spelling +using std::cout; +using std::cin; + +int main() +{ + double ProductionHours, + PreProductionHours, + ProducersHours, + ProductionCost, + PreProductionCost, + ProducersCost, + TotalCost; + //Fixed tabbing + + const double PRODUCTION_RATE = 1.10F, + PRE_PRODUCTION_RATE = 0.90F, + PRODUCERS_RATE = 1.35F; + //Added arbitrary process constants (not specified in the book) + + cout << "Enter Production Hours: "; + cin >> ProductionHours; + cout << "\nEnter Pre-Production Hours: "; + cin >> PreProductionHours; + cout << "\nEnter Producers Hours: "; + cin >> ProducersHours; + + ProductionCost = ProductionHours * PRODUCTION_RATE; + PreProductionCost = PreProductionHours * PRE_PRODUCTION_RATE; + ProducersCost = ProducersHours * PRODUCERS_RATE; + //Fixed missing vars - see [Added arbitrary process constants] + + TotalCost = ProductionCost + PreProductionCost + ProducersCost; + //Fixed inconsistent capitalization + + cout << "\n\t\tCar Dealership Bill\n"; + cout << "\n\nProduction Cost: "; + cout << ProductionCost; + + cout << "\n\nPre-Production Cost: "; + cout << PreProductionCost; + + cout << "\n\nProducers Cost: "; + cout << ProducersCost; + + cout << "\n\nWeekly Total Cost: "; + cout << TotalCost << std::endl; + //Fixed syntax + + return 0; +} +*/ diff --git a/Lab2Harris-Toovy/Lab2 console output Harris-Toovy.txt b/CST116F2021-Lab2/Lab2-Console_output.txt index 2fec042..26f0b86 100644 --- a/Lab2Harris-Toovy/Lab2 console output Harris-Toovy.txt +++ b/CST116F2021-Lab2/Lab2-Console_output.txt @@ -1,3 +1,6 @@ +This file contains the console outputs for each code block (one per exercise) - Jordan Harris-Toovy, October 2021 +NOTE: The file names and paths have changed due to reorganization, however, the code is identical. + CONSOLE OUTPUT FOR CODE 3c (4.13#2): C @@ -27,6 +30,7 @@ Press any key to close this window . . . CONSOLE OUTPUT FOR CODE 4a (5.4#2): + First Name GPA Class Major Credits Bob 3.23 Freshman Software Engineering 23 Jamie 0.98 Freshman Underwater Basket 15 @@ -37,3 +41,38 @@ Webster 2.00 Sophomore Wildlife Management 56 C:\Users\jorda\Source\Repos\cst116-lab2-JordanHT-OIT\Lab2Harris-Toovy\Debug\Lab2Harris-Toovy.exe (process 11020) exited with code 0. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. Press any key to close this window . . . + + +CONSOLE OUTPUT FOR CODE 4b (5.9): + +You have $123.45 +Enter percent raise: 15 +After your raise you have $141.967 + +C:\Users\jorda\Source\Repos\cst116-lab2-JordanHT-OIT\Lab2Harris-Toovy\Debug\Lab2Harris-Toovy.exe (process 3636) exited with code 0. +To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. +Press any key to close this window . . . + + +CONSOLE OUTPUT FOR CODE 4b (5.10): + +Enter Production Hours: 12 + +Enter Pre-Production Hours: 3 + +Enter Producers Hours: 5 + + Car Dealership Bill + + +Production Cost: 13.2 + +Pre-Production Cost: 2.7 + +Producers Cost: 6.75 + +Weekly Total Cost: 22.65 + +C:\Users\jorda\Source\Repos\cst116-lab2-JordanHT-OIT\Lab2Harris-Toovy\Debug\Lab2Harris-Toovy.exe (process 7288) exited with code 0. +To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. +Press any key to close this window . . . diff --git a/Lab2Harris-Toovy/Lab2 Textual work Harris-Toovy.txt b/CST116F2021-Lab2/Lab2-Textual_work.txt index 2c67cf9..e3548f1 100644 --- a/Lab2Harris-Toovy/Lab2 Textual work Harris-Toovy.txt +++ b/CST116F2021-Lab2/Lab2-Textual_work.txt @@ -70,6 +70,3 @@ Display Class_score 5) a = 1 6) a = 0.6 7) Invalid syntax, would be a = 4 if rearranged - - - diff --git a/Lab2Harris-Toovy/Lab2Harris-Toovy.cpp b/Lab2Harris-Toovy/Lab2Harris-Toovy.cpp deleted file mode 100644 index 3716e08..0000000 --- a/Lab2Harris-Toovy/Lab2Harris-Toovy.cpp +++ /dev/null @@ -1,100 +0,0 @@ -//Code by Jordan Harris-Toovy for OIT'S CST116-01P Lab 2 - October 2021 -//Un-comment blocks for each assignment (re-comment when finished) - -#include <iostream> -#include <iomanip> - -//PART 3c - 4.13#2: -/* -using std::cout; - -int main() -{ - char ascii = 67; - cout << ascii << '\n'; - ascii = 43; - cout << ascii << '\n'; - cout << ascii << '\n'; - - return 0; -} -*/ - -//PART 3c - 4.13#3: -/* -using std::cout; - -int main() -{ - int myAgeYears = 24; - int myAgeDays; - const int yearDays = 365; - - myAgeDays = myAgeYears * yearDays; - - cout << "I am " << myAgeDays << " Days old."; - - return 0; -} -*/ - -//PART 4a - 5.4#1: -/* -using std::cout; -using std::cin; - -int main() -{ - float body_temp; - cout << "Enter you body temperature: "; - cin >> body_temp; - - cout.setf(std::ios::fixed); - cout.width(6); - cout << std::setprecision(1) << body_temp; - - return 0; -} -*/ - -//PART 4a - 5.4#2: -/* -using std::cout; -using std::cin; -using std::setw; -using std::endl; - -int main() -{ - const int padding1 = 15; - const int padding2 = 30; - - cout.setf(std::ios::fixed); - cout.setf(std::ios::left); - - - cout << setw(padding1) << "First Name" << setw(padding1 - 5) << "GPA" << setw(padding1) << "Class" << setw(padding2) - << "Major" << setw(padding1) << "Credits" << endl; - - cout << setw(padding1) << "Bob" << setw(padding1 - 5) << std::setprecision(2) << 3.23 << setw(padding1) << "Freshman" << setw(padding2) - << "Software Engineering" << setw(padding1) << std::setprecision(0) << 23 << endl; - - cout << setw(padding1) << "Jamie" << setw(padding1 - 5) << std::setprecision(2) << 0.98 << setw(padding1) << "Freshman" << setw(padding2) - << "Underwater Basket" << setw(padding1) << std::setprecision(0) << 15 << endl; - - cout << setw(padding1) << "Marcus" << setw(padding1 - 5) << std::setprecision(2) << 4.00 << setw(padding1) << "Freshman" << setw(padding2) - << "Management" << setw(padding1) << std::setprecision(0) << 3 << endl; - - cout << setw(padding1) << "Phong" << setw(padding1 - 5) << std::setprecision(2) << 3.75 << setw(padding1) << "Junior" << setw(padding2) - << "Encryption" << setw(padding1) << std::setprecision(0) <<101 << endl; - - cout << setw(padding1) << "Webster" << setw(padding1 - 5) << std::setprecision(2) << 2.00 << setw(padding1) << "Sophomore" << setw(padding2) - << "Wildlife Management" << setw(padding1) << std::setprecision(0) << 56 << endl; - - return 0; -} - -*/ - -//PART 4a - 6.3#1 -//WORK IN PROGRESS
\ No newline at end of file diff --git a/Lab2Harris-Toovy/Lab2Harris-Toovy.vcxproj b/Lab2Harris-Toovy/Lab2Harris-Toovy.vcxproj deleted file mode 100644 index 41e2359..0000000 --- a/Lab2Harris-Toovy/Lab2Harris-Toovy.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <VCProjectVersion>16.0</VCProjectVersion> - <Keyword>Win32Proj</Keyword> - <ProjectGuid>{bfe423e7-6a30-4a96-834e-9be88ccbe4a6}</ProjectGuid> - <RootNamespace>Lab2HarrisToovy</RootNamespace> - <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Label="Shared"> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <LinkIncremental>true</LinkIncremental> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <LinkIncremental>false</LinkIncremental> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <LinkIncremental>true</LinkIncremental> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <LinkIncremental>false</LinkIncremental> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClCompile Include="Lab2Harris-Toovy.cpp" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ No newline at end of file diff --git a/Lab2Harris-Toovy/Lab2Harris-Toovy.vcxproj.filters b/Lab2Harris-Toovy/Lab2Harris-Toovy.vcxproj.filters deleted file mode 100644 index cf279b2..0000000 --- a/Lab2Harris-Toovy/Lab2Harris-Toovy.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="Source Files"> - <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> - <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> - </Filter> - <Filter Include="Header Files"> - <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> - <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions> - </Filter> - <Filter Include="Resource Files"> - <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> - <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> - </Filter> - </ItemGroup> - <ItemGroup> - <ClCompile Include="Lab2Harris-Toovy.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> -</Project>
\ No newline at end of file |