Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Distant Wishes This problem focuses on building a basic Distance class, which supports input in both meters and feet/inches. You should start this program with

Distant Wishes This problem focuses on building a basic \"Distance\" class, which supports input in both meters and feet/inches. You should start this program with the distance.cpp file on the website. You are expected to add code at the top to make the main function that is provided work as expected. The provided main function is relatively simple, it asks the user to input two distances and then compares them to indicate which is bigger. You may not change main(), we will check to ensure it is exactly (letter-to-letter) the same. Users can enter distances in two formats: metric system (a single number measured in meters. Example: 13.4m) or United States customary system (a distance measured in feet and inches. Example: 3'4.7\" 3 feet, 4.7 inches). Some assumptions you can make to simplify this problem: 1. The user will either input meters or feet/inches - you don't have to worry about other input formats or invalid inputs. 2. Feet will always be a whole number, inches will always be between 0 and 12. 3. meters and inches can be real numbers. 4. Use the conversation that 1 foot = 0.305 meters Hints  You will need to design the Distance class. Do not over-complicate this class, and do not design it specifically based on the input formats Think about what is the minimum you need to store a single distance and work backwards from there instead. You may be tempted to give this lots of instance variables, but the fewer instance variables this has, the simpler the code will likely be.  Make sure to use the specific unit conversions listed above  While you don't need to implement any behavior not currently used by main, don't be afraid to use this as a chance to further practice building out a C++ class.  don't copy any quotes or apostrophes from this PDF. they probably are not going to be the correct letter (I.E. they are not the same letter-code as the letter you type with your keyboard)  to type the char' (apostrophe) you need to use the escape character. So the char would be typed as ' Examples Example 1 Enter two distances: 3 12'3\" 3.4m First distance is larger Example 2 Enter two distances: 305m 1000'0\" Same distances Example 3 Enter two distances: 5'1.23456\" 5'1\" First distance is larger Submission When you are done, name the source code file hw10A.cpp. Then log into gradescope and upload your file for the Homework 10A submission. If you name your file incorrectly it will be unable to compile and run your code, so you will fail all test cases. You may submit cpp files as many times as you want until the deadline to try and fix the code if you fail a test case. Following rigorous naming conventions and using test cases are something computer programmers often must do in real life programming, and so submitting your program with the correct name and functionality is part of doing this assignment correctly. #include 3 using namespace std; 4 - N O P LO O N O C 6 // DO NOT MAKE ANY CHANGE TO THIS LINE OR ANY LINE BELOW THIS ONE 7 || ANY CHANGE HERE OR BELOW WILL CAUSE ALL TESTS TO FAIL. int main() 9 { 10 Distance di, d2; 11 cout > d1 >> d2; 13 14 if(d1 

C++ Programming



Distance.cpp

3 using namespace std; 4 - N O P LO O N O C 6 // DO NOT MAKE ANY CHANGE TO THIS LINE OR ANY LINE BELOW TH\" v:shapes=\"_x0000_i1202\">




Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Programming questions

Question

What do labour unions do for their members?

Answered: 1 week ago