Write a program that allows the user to input the r- and y-coordinates of two squares, and then prints out whether or not they form a valid ship – meaning that both squares lie on the grid, and are adjacent to one another horizontally or vertically. If one of those conditions is not met, the program should print out a message saying which condition is wrong. (If both conditions are not met, the program only needs to output a single message, which can be either one, your choice.) For example, here is a sample run: Enter x-coordinate of square one: 3 Enter y-coordinate of square one: 2 Enter x-coordinate of square two: 3 Enter y-coordinate of square two: 3 Valid - here, the numbers are input by the user, and everything else is produced by the program; this is Valid because it corresponds to the first placement shown in the figure above. Other sample runs might look like: Enter x-coordinate of square one: 3 Enter y-coordinate of square one: -1 Enter x-coordinate of square two: 5 Enter y-coordinate of square two: 2 Square(s) not on grid
Write a program that allows the user to input the r- and y-coordinates of two squares, and then prints out whether or not they form a valid ship – meaning that both squares lie on the grid, and are adjacent to one another horizontally or vertically. If one of those conditions is not met, the program should print out a message saying which condition is wrong. (If both conditions are not met, the program only needs to output a single message, which can be either one, your choice.) For example, here is a sample run: Enter x-coordinate of square one: 3 Enter y-coordinate of square one: 2 Enter x-coordinate of square two: 3 Enter y-coordinate of square two: 3 Valid - here, the numbers are input by the user, and everything else is produced by the program; this is Valid because it corresponds to the first placement shown in the figure above. Other sample runs might look like: Enter x-coordinate of square one: 3 Enter y-coordinate of square one: -1 Enter x-coordinate of square two: 5 Enter y-coordinate of square two: 2 Square(s) not on grid
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Simple python
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education