This file contains hidden or 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 "What is the amount due?" | |
amount_due = gets.chomp | |
if (amount_due[/^[1-9]\d*(\.\d+)?$/] == false) || (amount_due.scan(/\./).length > 1) | |
puts "Warning: Invalid currency detected! Exiting..." | |
abort | |
end | |
puts "What is the amount tendered?" | |
amount_tendered = gets.chomp |
This file contains hidden or 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
MAX = 30 | |
random_number = rand(MAX+1) #This makes the range of possible number 0 to MAX, inclusive. | |
user_correct = false | |
while user_correct == false do | |
print "Guess number between 0 and #{MAX}: " | |
user_guess = gets.chomp | |
if ((0..MAX).include?(user_guess) == false) || user_guess[/\D/] == true | |
puts "Invalid input, must enter a number between 0 and #{MAX}." |
This file contains hidden or 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
commit 7e63f72b9540763370ac16b1ddd474a452af8f65 | |
Author: faizaanshamsi <[email protected]> | |
Date: Thu Nov 14 19:56:56 2013 -0500 | |
added /app/views/README.md to .gitignore | |
commit 05ccf2e6b8ff714e605b8c0b3d4e672a9a61d981 | |
Author: faizaanshamsi <[email protected]> | |
Date: Thu Nov 14 19:50:43 2013 -0500 |
This file contains hidden or 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
all_prices = [] | |
price = "" | |
until price == "done" do | |
puts "What is the sale price?" | |
price = gets.chomp | |
if !price.match(/\A\d+(\.\d+)?\z/) |
This file contains hidden or 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
scores_raw = [75, 100, 85, 65, 84, 87, 95] | |
scores = scores_raw.sort | |
sum = scores.inject(0) { |total, x| total + x} | |
average = sum/(scores.length) | |
puts "The Average Score is #{average}" |
This file contains hidden or 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
#!/usr/bin/env ruby | |
word_bank = ["this", "is", "the", "word", "bank"] | |
word = word_bank.sample | |
remaining_guesses = 10 | |
guess = "" | |
display = "_" * word.length | |
until guess == word || remaining_guesses == 0 || display == word | |
puts "Word : #{display}" |
This file contains hidden or 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
salutations = [ | |
'Mr.', | |
'Mrs.', | |
'Mr.', | |
'Dr.', | |
'Ms.' | |
] | |
first_names = [ | |
'John', |
This file contains hidden or 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
def menu(hash) | |
i = 1 | |
hash.each do |k, v| | |
puts "#{i}) Add item - $#{decimal_output(v[0])} - #{v[1]}" | |
i += 1 | |
end | |
puts "#{i}) Complete Sale" , "" | |
end | |
def prompt(string) |
This file contains hidden or 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
data = [ | |
{ | |
home_team: "Patriots", | |
away_team: "Broncos", | |
home_score: 7, | |
away_score: 3 | |
}, | |
{ | |
home_team: "Broncos", | |
away_team: "Colts", |
This file contains hidden or 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
song = "***DON'T STOP...BELIEVIN'!*** | |
Just a small town girl | |
Living in a lonely world | |
She took the midnight train going anywhere | |
Just a city boy | |
Born and raised in South Detroit | |
He took the midnight train going anywhere | |
A singer in a smoky room |
OlderNewer