Question

Created a method in RUBY that is named using_while method so that calling it will puts...

Created a method in RUBY that is named using_while method so that calling it will puts the desired phrase while your number is less than 10. Remember, every time you puts the phrase, you should increment your number by 1.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

RUBY METHOD WITH WHILE LOOP IN IT:

Code Snippet:

def using Loop(num1, num2) while numi<=num2 puts UsingWhileLoopInRuby num1 = num1 + 1 end end #Fucntion name with arguments

Output Snippet:

UsingWhileLoopInRuby UsingWhileLoopInRuby UsingWhileLoopInRuby UsingWhileLoopInRuby UsingWhileLoopInRuby UsingWhileLoopInRuby

Code in Text format:

def usingLoop(num1, num2)                  
   while num1<=num2                      
       puts "UsingWhileLoopInRuby"         
       num1 = num1 + 1                      
    end                                    
end                                          
puts(usingLoop(1,10))                      


Your mentioned all conditions are fulfilled.

I hope this will help you!

Thank you!

Add a comment
Know the answer?
Add Answer to:
Created a method in RUBY that is named using_while method so that calling it will puts...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE DO THIS IN RUBY # Write a method bigger_filter that accepts an array of numbers...

    PLEASE DO THIS IN RUBY # Write a method bigger_filter that accepts an array of numbers and a target number. The method should return a new array containing the elements that are greater than the given target. def bigger_filter(arr, tar) end print bigger_filter([7,3,2,8,12], 5) # => [7, 8, 12] #puts print bigger_filter([1,2,3], 100) # => [] #puts print bigger_filter([10,9,20,3], 9) # => [10, 20] MY ATTEMPT def bigger_filter(arr, tar)    new_arr = []    i = 0    while i...

  • Write a class named Month. The class should have an int field named monthNumber that holds...

    Write a class named Month. The class should have an int field named monthNumber that holds the number of the month. For example. January would be 1. February would be 2. and so forth. In addition, provide the following methods A no-arg constructor that sets the monthNumber field to 1 A constructor that accepts the number of the month as an argument. It should set the monthNumber field to the value passed as the argument. If a value less than...

  • (Python) Extend the function num_permutation_sequence(n) so that calling send(o) method causes the generator to increment n instead of k for the next number to generate.

    using this functiondef num_permutation_sequence(n):these are the test casesg = num_permutation_sequence(3)assert (next(g), next(g), g.send(0), next(g), next(g), next(g),g.send(0)) == (1, 3, 4, 12, 24, 24, 120)Exercise (Challenge) Extend the function num_permutation_sequence(n) so that calling send(o) method causes the generator to increment n instead of k for the next number to generate. i.e., for 0 <k <n, send(O) . Pn,k-1 ? Pnik Pn+1,6 ? Pn+1,5+1 (7) where without labels is the normal transition without calling the send method. Hint: n + 1 Pn+1,6...

  • 1. What is the result of calling the append method on a list? 2. What must...

    1. What is the result of calling the append method on a list? 2. What must be defined prior to using a method like append? 3. Explain why two lines caused an IndexError. 4. What is the result of calling the remove method on a list? 5. Give one example of a list method that requires an argument and one that does not. 6. Describe the syntax similarities and differences between using a list method like append and Python built-in...

  • I Need Help with this using Java Programming : Class name fname lname Class variable total...

    I Need Help with this using Java Programming : Class name fname lname Class variable total Number Constructor (no arguments) Constructor (takes two arguments, fname and lname) One getter method to return the fname and lname One setter method for fname and lname Inside Main: Create three objects with the following names Jill Doe John James Jack Smith When creating the first object (Should not be an anonymous object) use the argument-less constructor Then use the setter method to assign...

  • Java arrays Create method named repeatedN that takes two integer parameters named range and n and...

    Java arrays Create method named repeatedN that takes two integer parameters named range and n and returns an integer array Method should return an integer array that has numbers 0 - range repeated in order n times If range is less than or equal to 0; return an array that has 0 repeated n times Create a second method named printArray that takes an integer array as a parameter. The method should print out every element on the same line...

  • JAVA PROG HW Problem 1 1. In the src −→ edu.neiu.p2 directory, create a package named...

    JAVA PROG HW Problem 1 1. In the src −→ edu.neiu.p2 directory, create a package named problem1. 2. Create a Java class named StringParser with the following: ApublicstaticmethodnamedfindIntegerthattakesaStringandtwocharvariables as parameters (in that order) and does not return anything. The method should find and print the integer value that is located in between the two characters. You can assume that the second char parameter will always follow the firstchar parameter. However, you cannot assume that the parameters will be different from...

  • ****WRITE A JAVA PROGRAM THAT : Write a method named stretch that accepts an array of...

    ****WRITE A JAVA PROGRAM THAT : Write a method named stretch that accepts an array of integers (that the user inputs) as a parameter and returns a new array twice as large as the original, replacing every integer from the original array with a pair of integers, each half the original. If a number in the original array is odd, then the first number in the new pair should be one higher than the second so that the sum equals...

  • Write a class named DiceGame.java that contains a method called diceSum that prompts the use for...

    Write a class named DiceGame.java that contains a method called diceSum that prompts the use for a desired sum, then repeatedly simulates the rolling of 2 six-sided dice until their sum is the desired sum (use a do/while loop). Here is a sample dialogue with the user: Desired dice sum: 9 4 and 3 = 7 3 and 5 = 8 5 and 6 = 11 5 and 6 = 11 1 and 5 = 6 6 and 3 =...

  • a ruby program problem **************************************************************************** Ruby These short language exercises are intended to help you to...

    a ruby program problem **************************************************************************** Ruby These short language exercises are intended to help you to explore new languages with differing paradigms and syntax. In this assignment you will complete a Ruby program. I will give you help on where and what to look for in Ruby to assist you. Write a Ruby program to solve the following problem: Open a file that has a list of scores between 0 and 100. There may be as many as 100 scores...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT