Im trying to make this program using Ruby but Im messing som

I\'m trying to make this program using Ruby, but I\'m messing something up in the code.

The “name” program will input/output depicted below:

Here\'s the code that I have:

puts
puts \"what\'s Your Name?\"
name=gets.chomp
if name ==\"\"
   puts \"Try again\"
elsif name==\"Mary\"
   puts \"Hello Mary!\"
else puts \"Try something else\"
end

C:\\Windows system32\\cmd.exe what\'s Your Name? mary Hello Mary!

Solution

puts \"what\'s Your Name?\"
name=gets.chomp //This removes the newline character
if name == \' \' //Here single quotes will go
   puts \"Try again\"
elsif name==\"Mary\"
   puts \"Hello Mary!\"
else puts \"Try something else\"
end

I\'m trying to make this program using Ruby, but I\'m messing something up in the code. The “name” program will input/output depicted below: Here\'s the code th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site