Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that prompts the user for two x and y coordinates. The program then prints two moves that will take the user from

Write a program that prompts the user for two x and y coordinates. The program then prints two moves that will take the user from the first coordinate to the second using the shortest possible distance. Each move consists of a distance and a direction: up, down, left, right, up-left, up-right, down-left, and down-right. The directions are essentially the same as in the previous problem, though the four diagonal directions affect both the x and y coordinates. Unlike the previous problem, all distances must be positive or 0. You may use moves of distance 0 if you only need 1 (or 0) moves to reach the destination. Hint: to find the shortest possible path, you will need to use the diagonal directions if possible. Start by deciding on a basic direction and which coordinate is closer to the target. Sample output: Enter the starting x coordinate: 0 Enter the starting x coordinate: 0 Enter the ending x coordinate: 1 Enter the ending y coordinate: 4 Shortest path: move 1 unit(s) up-right, then 3 unit(s) up Sample output with a move of distance 0: Enter the starting x coordinate: 2 Enter the starting y coordinate: -1 Enter the ending x coordinate: 0 Enter the ending y coordinate: 1 Shortest path: move 2 unit(s) up-left, then 0 unit(s) up

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago