Skip to content

Instantly share code, notes, and snippets.

View sheland's full-sized avatar

Shelan sheland

View GitHub Profile
#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.
#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"
#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
@sheland
sheland / Election.rb
Created July 17, 2018 13:41
Day 3 - Election assignment
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
# 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
@sheland
sheland / Day_4_Password Verification.rb
Last active July 31, 2018 03:50
Password Program
#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
@sheland
sheland / Student_generator.rb
Last active August 1, 2018 19:03
A program that generates student information.
#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 = []
#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.
#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 = []
#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."