This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Day 1 Exercises Problem #1 | |
#Last edited by Shelan 7/29/18 | |
# Takes in input from the user and outputs a madlib story | |
# Bad style example | |
# susan evans | |
# Last edited 11/25/2016 | |
#Madlib program intakes user's information and then outputs short paragraph based | |
#user's information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Day 1 MadLib | |
#Last edited 7/29/18 | |
#Takes input from the user and outputs a madlib story | |
#print introduction message for the user | |
print "Welcome to the \"Summer Fun\" MadLib, please enter the following information below.\n\n" | |
#user input data | |
print "Pick a name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1. | |
puts "If the number is greater than 70, print PASSING; otherwise, print NOT PASSING what is x?" | |
puts "Enter a number" | |
x = gets.chomp.to_i | |
if x > 70 | |
puts "PASSING" | |
elsif x < 70 | |
puts "NOT PASSING" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Welcome to the election voting program" | |
puts "The candidates are: Sara, Sally, Suzie, Sandy" | |
puts "Who are you voting for?" | |
# input 10 votes | |
results = (1..10).each.with_object(Hash.new(0)) do |i, hash| | |
candidate = gets.chomp | |
hash[candidate] += 1 | |
puts "Vote #{i}: <#{candidate}>" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Day 3 Exercises | |
# Updated 07/30/2018 | |
#1. | |
# Write a program that allows a user to play a guessing number game. | |
# Your program should generate a random number between 0 – 1000 (including 0, but not including 1000). | |
# Allow the user to make a guess until they guess the answer. After each guess you should print "higher" or "lower". | |
# When they guess it correctly print a winning message along with their total number of guesses. | |
#prints welcome message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Day 4 JSL | |
#Updated 7/30/18 | |
#Create a program that will: | |
#Prompt a user for input (for a new password) | |
#Read in the proposed Password to a variable | |
#If the password contains a number and a symbol (@, %, \*, or !) | |
#and contains 8 or more characters then accept the password and congratulate the user, | |
#if not make them reenter the password until they enter an acceptable password | |
#[Optional] Make the user enter the password a second time to verify, and if it's |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Day 5: Student Account Generator | |
#Revised 7/30/18 | |
#Write a program that generates some student information. The program will have the following: | |
#An array that contains student names | |
#An array that stores student ID numbers | |
#An array that contains student email addresses | |
# Arrays | |
names = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Day 5 Excercises | |
#Revised 07/30/18 | |
#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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Day 6 Exercises | |
#Updated 7/30/18 | |
#1 | |
#Ask the user to enter the names, ages, and favorite colors of their closest friends | |
#(you may not assume that the user's close friends all have unique names). | |
#Output the total number of close friends under 18, followed by their names. | |
#Output the number of unique favorite colors, and then list them | |
friends = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#How would you modify the code below to improve the code style and readability? | |
foods = ["shrimp", "cauliflower", "salmon", "garlic", "oysters", | |
"salami", "tomatoes", "okra", "zucchini", "avocado"] | |
print "How many foods would you like to see? I suggest 10, but it's up to you. " | |
items = gets.chomp.to_i | |
if items > 10 | |
puts "Best I can do is 10. Let's do 10." |
OlderNewer