Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m not a programmer nor a computer science person but my friend is and he need

ID: 663402 • Letter: I

Question

I'm not a programmer nor a computer science person but my friend is and he needs help.

He needs to write a program using RUBY, The code should prints the numbers one through 150, but with three caveats:

1) If the number is a multiple of three, the program should print flat!

2) If the number is a multiple of four, the program should print iron

3) If the number is a multiple of both three and four, the program should print flatiron, therefore, the first teen lines that get printed out should read:

1

2

flat

iron

5

flat

7

iron

flat

10

Explanation / Answer

for i in 1..150

if ((i%3) == 0) and ((i%4)==0)
puts "flatiron"
elsif ((i%3) == 0)
   puts "flat"
elsif ((i%4)==0)
puts "iron"
else
puts i
end

end

-------------------------OUTPUT-----------------------------

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote