Skip to content

Latest commit

 

History

History

day5

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

JumpStart Live (JSL)

Day 5

Prep Work

Warm up

  • Share what you learned from our last two sessions about loops
  • Walk your partner though your Student Account Generator Part 1 code focusing on using programming vocabulary (e.g, arrays, index, value, blocks, loops, iterator, variable assignment)

Lessons

Exercises

Required Problems

In one Ruby file, write code to solve the problems below. Your code should print out each problem statement, followed by the described output.

  1. Create an array to store 5 names. Have the user enter in the 5 names and then print out the 5 names in all UPPERCASE all on the same line. Note that the user may not enter all the names in uppercase.
  2. Create an array to store 3 boolean values entered in by the user. Print out YES if all the values are true and NO if at least one value is false. Hint: Prompt the user to enter true or false, and accept those values using gets. Since gets will give us back a string (instead of the boolean values we want) use if statements to convert those strings to boolean values.
  3. Create an array to store the following words: firetruck, fire drill, fire hydrant, firefighter, fireproof, fire station, fire hose. Then write code that uses the array to print out truck, drill, hydrant, fighter, proof, station, hose without modifying the array.
  4. Create an array to store the amount of money spent on 4 people during the Holidays. Have the user enter in the amount spent on each person. Print the total spent on all the people. Total money spent should be displayed with a dollar sign, decimal point, and only 2 digits after the decimal.
  5. Create an array to store 5 random numbers (between 1 and 10, including both 1 and 10) generated by the computer. Print out the square of each of the elements in the array.
  6. Create an array to store 5000 decimal numbers. Randomly generate numbers from between 0 – 1 (including 0, but not including 1) to fill the array. Calculate and print the mean of all the elements in the array.

Optional Problems

In one Ruby file, write code to solve the problems below. Your code should print out each problem statement, followed by the described output.

  1. Create an array of people that are invited to a party. Allow the user to ask if a certain person is invited to the party. If the person is on the invitation list respond INVITED otherwise respond NOT INVITED.
  2. Have the user enter in a sentence. Then, using an array, store the frequency of each letter of the alphabet from the sentence. Print out the frequency of each letter. Do not count uppercase and lowercase letters differently.
  3. Create an array of size 8. Fill the array randomly with 0’s and 1’s. Print out the array so that it appears as a binary number. Calculate and print out the decimal value of that binary number.

Debrief

  • Why are arrays useful in programming?
  • What topics are you still struggling with?
  • What did you especially enjoy about today's class?
  • What can be improved for future classes?

Resources

Homework