-
Notifications
You must be signed in to change notification settings - Fork 42
/
pseudocode.rb
75 lines (64 loc) · 2.04 KB
/
pseudocode.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
##################
### OBJECTIVE: ##
##################
# Write a Deaf Grandma program. Whatever you say to grandma (whatever you type in), she should respond with HUH?! SPEAK UP, SONNY!, unless you shout it (type in all capitals). If you shout, she can hear you (or at least she thinks so) and yells back, NO, NOT SINCE 1938!
#INPUT:
#A string of a sentence we are saying to grandma
#examples: "Hi Grandma!", "BYE", "HAVE YOU SEEN THE NEWS?"
#OUTPUT:
#To exit the loop if given string: "BYE"
#The string: "HUH!? SPEAK UP, SONNY!" if given a random string not in all upcase
#The string: "NO, NOT SINCE 1938!" if given a random string in all uppercase
###########################
### PSEUDOCODE EXAMPLE: ##
###########################
# PROGRAM dear_grandma method
# Keep LOOPING to get more input
# Prompt user for input
# Ask what to say to grandma
#
# IF we said "BYE"
# stop asking for more input and leave
# END
#
# IF what I just said is too quiet
# Grandma responds "HUH!? SPEAK UP, SONNY!"
# ELSE
# Grandma responds "NO, NOT SINCE 1938!"
# END
#
# END
# END
###########################
### PSEUDOCODE EXAMPLE ##
### WITH ##
### SOURCE CODE ##
###########################
# def dear_grandma
#
# # Keep LOOPING to get more input
# while true
#
# # Ask the user what to say to grandma
# puts "What do you want to say to Grandma?"
# tell_grandma = gets.chomp
#
# # IF we said "BYE"
# if tell_grandma == "BYE"
# # stop asking for more input and leave
# break
# # END
# end
#
# # IF what I just said is too quiet
# if tell_grandma.upcase != tell_grandma
# # Grandma responds "HUH!? SPEAK UP, SONNY!"
# puts "HUH!? SPEAK UP, SONNY!"
# # ELSE
# else
# # Grandma responds "NO, NOT SINCE 1938!"
# puts "NO, NOT SINCE 1938!"
# # END
# end
# end
# end