Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a loop that asks the user the enter in values for the horizontal and vert

ID: 3660468 • Letter: C

Question

Create a loop that asks the user the enter in values for the horizontal and vertical distance travelled, as in the example below. The loop should repeat three (3) times as shown. The total horizontal and vertical distances moved should be updated with each entry by the user. Note that distances can be positive or negative (think 2 D x-y grid with the car starting at the center (0,0)) 4) Call the print_location function to print final location of the car EXAMPLE PRINTOUT: Please enter a horizontal distance: 10 Please enter a vertical distance: 10 Please enter a horizontal distance: 12 Please enter a vertical distance: -5 Please enter a horizontal distance: 5 Please enter a vertical distance: 7 Final Location: horizontal = 27 vertical = 12 distance from origin = 29.55

Explanation / Answer

#include #include using namespace std; string getMake(); int getYear(); void setSpeed(int); void setYear(int); void setMake(string); class Car { private: int year,speed; string make; public: Car(int newYear, string newMake) { year=newYear; void setYear(); make=newMake; speed=0; }; int getSpeed() //get speed function {return speed;} void Car::setYear(int newYear) //function to set year to 2012 if it receives a value inbewteen 1900 and 2030 { if(newYear2030) year=2012; else year = newYear; } void setSpeed(int speed) //function to set the speed to 0 if it recives a negitive value { if(speed=5) speed-=5; else speed=0; } int getYear() { return year; } string getMake() { return make; } int main() { Car objectCar(2010,"Mazda"); cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote