diff options
| author | tafaar <[email protected]> | 2022-10-14 20:40:40 -0700 |
|---|---|---|
| committer | tafaar <[email protected]> | 2022-10-14 20:40:40 -0700 |
| commit | a7c7b3242d51191423c84051f3402148102e0150 (patch) | |
| tree | b8f612bb42f03aa2fcaf8ffa251f29f332fe80b2 | |
| parent | Setting up GitHub Classroom Feedback (diff) | |
| download | cst116-lab1-hill-a7c7b3242d51191423c84051f3402148102e0150.tar.xz cst116-lab1-hill-a7c7b3242d51191423c84051f3402148102e0150.zip | |
Set up the project
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 47 | ||||
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.vcxproj | 8 |
2 files changed, 45 insertions, 10 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index ed5f807..f58bec3 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -1,16 +1,51 @@ -// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - #include <iostream> -using namespace std; - using std::cout; using std::cin; using std::endl; +float width; +float length; + + int main() { - cout << "Hello World!\n"; + cout << std::fixed; + cout.precision(3); + + cout << "Please enter the width of your kite in centimeters. Use values between 1 - 400 cm." << endl; + + do { + + cin >> width; + if (width < 1 || width > 400) cout << "Please try again with a value between 1 - 400" << endl; + + } while ( width > 400 || width < 1); + + cout << "Now enter the length, again between 1 - 400cm." << endl; + + do { + + cin >> length; + if (length < 1 || length > 400) cout << "Please try again with a value between 1 - 400" << endl; + + } while (length > 400 || length < 1); + + cout << "The dimensions of your kite are " << width << "cm by " << length << "cm." << endl; + + double area = (width * length) / 10000.0; + float aspectRatio = width / length; + + cout << "The area is " << area << " square meters." << endl; + cout << "The aspect ratio is " << width / length << endl; + + if (aspectRatio >= 1) { + cout << "A lower aspect ratio might provide better stability." << endl; + } + + const float mass = 135.0f * area; + + cout << "Your kite has a mass of " << mass << " grams."; + } diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj index db2e734..d2e3ee2 100644 --- a/BlankConsoleLab/BlankConsoleLab.vcxproj +++ b/BlankConsoleLab/BlankConsoleLab.vcxproj @@ -29,26 +29,26 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> + <PlatformToolset>v143</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> + <PlatformToolset>v143</PlatformToolset> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> <WholeProgramOptimization>true</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> |