Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 Write a program that prompts the user for x and y coordinates, a direction, and a distance, then prints out the user's coordinates

Problem 1 Write a program that prompts the user for x and y coordinates, a direction, and a distance, then prints out the user's coordinates after moving the given distance in the given direction from the original position. If the user enters any direction other than "up", "down", "left", or "right", they will not move; just print out their original location. If they move up or down, add or subtract their distance (respectively) to the y coordinate. If they move right or left, add or subtract (respectively) the distance to the x coordinate. The user is allowed to enter a negative distances, and all coordinates and distances will be integers. Sample output: Enter the x coordinate: 3 Enter the y coordinate: 4 Enter the direction (up, down, left, or right): down Enter the distance to move: 5 Final destination: (3, -1)

Problem 2 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

Problem 3 Write a program that prompts the user to enter grades and stores all of these grades in a list. When the user enters a negative value, print out the mean and standard deviation of all grades to 2 decimal places and end the program. If the user entered a negative value as the first value, instead print a message that mean and standard deviation are undefined. The mean of n numbers x1, x2, ..., xn equals (x1 + x2 + ... + xn) / n, and the standard deviation of these numbers is sqrt(1/n * ((x1 - u)^2 + (x2 - u)^2 + ... + (xn - u)^2)), where u represents the mean. Sample output: Enter class grades (-1 when finished): 100 90 80 70 60 -1 Mean: 80.00 Standard deviation: 14.14

Problem 4 Write a program that prompts the user to enter a sentence and prints a disemvoweled version of that sentence 100 times. To "disemvowel" means to remove all of the vowels (a, e, i, o, and u) from the sentence. You should remove upper- and lowercase vowels, but non-vowel characters should stay the same. For this problem, y is not considered a vowel. Hint: create a second variable to store the "disemvoweled" version of the sentence. Sample output (abbreviated): Enter text: No, YOU'RE being toxic! N, Y'R bng txc! N, Y'R bng txc! N, Y'R bng txc! N, Y'R bng txc! N, Y'R bng txc! (repeated 95 more times)

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_2

Step: 3

blur-text-image_3

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

Schooltalk: Rethinking What We Say About and to Students Every Day

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago