Questions
You have been asked to write a program to check the validity of a password entered by a user into a computer system. The user will only have \(3\) attempts before being locked out of the system. The system will check the entered password against one stored.
- What would be an appropriate identifier and data type for the stored password?
- What would be an appropriate identifier and data type for the entered password?
- What would be an appropriate identifier and data type for the number of attempts?
- Describe using either a flowchart or pseudocode your algorithm for this problem
- Create a password program that asks the user for the password and checks it against one that you have made up. Inform the user if they have entered the correct password or not.
Additional Exercises
-
Display the ASCII characters associated with integers from 32 to 126 inclusive. Do not try to display those less than 32. (Why?) IDeally, present as a table with their decimal and hexadecimal equivalents. (Hint: You will need to look up how to convert a character into its ASCII code equivalent)
-
Write a program to generate the "Hailstone Sequence", also known as the Collatz Conjecture. This starts with any value, if the value is even divide by 2, if it is odd multiply by 3 and add 1. The conjecture states, whatever the start value the sequence will always reach 1.
-
Imagine you have a can of whipped cream. Every second the nozzle stays open, \(2\%\) of the remaining cream squirts out. How long, to the nearest second, will it take to empty half the can?
-
Write a loop that generates random numbers in the range \(1\) to \(100\) until ten numbers are generated in the range \(1\) to \(10\) and ten are in the range \(91\) to \(100\). How many numbers were generated in all?
-
Write a program to play "Fizz Buzz". For each number, between \(1\) and \(100\), that is evenly divisible by 3, output the word "Fizz". For each number that is evenly divisible by 5, output the word "Buzz". For each number that is evenly divisible by both 3 AND 5, output the word "FizzBuzz".
-
Write a program that prints a triangle of numbers from \(1\) to a given value \(n\) provided by the user. Your output should look like:
-
Write a program that reads from the console number \(N\) and print the sum of the first \(N\) members of the Fibonacci sequence: \(0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377\)