Once upon a time, there was a city that had no roads. Getting around the city was particularly difficult after rainstorms because the ground became very muddy—cars got stuck in the mud and people got their boots dirty. The mayor of the city decided that some of the streets must be paved, but didn’t want to spend more money than necessary because the city also wanted to build a swimming pool. The mayor, therefore, specified two conditions: 1. Enough streets must be paved so that it is possible for everyone to travel from their house to anyone else’s house only along paved roads, and 2. The paving should cost as little as possible. Here is the layout of the city. The number of paving stones between each house represents the cost of paving that route. Find the best route that connects all the houses, but uses as few counters (paving stones) as possible. <img src="https://codehs.com/uploads/10215864a5a3da7a4670edd1fadcaa85" width="450"> What strategies will you use to solve the problem? Be sure to remember how many paving blocks you used. You will need this number in the next exercise.
For this exercise, you will write a program that asks a user to create a password that is at least 6 characters long and store it in a variable called password. If the user enters a password that is too short display the statement, `Your password is too short! Enter a longer password.` Then ask the user to enter a password of the appropriate length. If they enter a password that is too short again the program should end and display the statement `Too bad your password is too short.` If the password they entered is sufficient in length, the user is prompted to re-enter their password to validate their first entry. If the user enters the password correctly display the statement `Your passwords match!` If the user re-enters the password incorrectly display the statement `This password does not match your first entry.` The user is prompted to re-enter the password again and the program checks if the re-entry matches the original password with the same display statements as above. Here is a sample output for the program: ``` Enter a password that is at least 6 characters long: Pa$sw Your password is too short! Enter a longer password. Enter a password of the appropriate length: Mypassword Re-enter your password for validation: MyPassword This password does not match your first entry. Re-enter your password for validation: Mypassword Your passwords match! ``` **Hint:** To get the length of a string, we use the `.length` command. For examples: ``` var name = "karel"; println(name.length); // Prints 5 ```
Sign up for a free teacher account to get access to curriculum, teacher tools and teacher resources.Teacher Signup
Sign up as a student if you are in a school and have a class code given to you by your teacher.Student Signup