Answered>Order 16402

Hi,

I need help completing my Ruby Programming assignment.

The assignment is:

The process of finding the largest value is used frequently in computer applications. For example, a program that determines the winner of a sales contest would input

the number of units sold by each salesperson. The salesperson who sells the most units wins the contest. Make a Ruby application that allows a user to input a series of 10 integers and determines and prints the largest integer. Your program should use at least the following three variables:

a) counter: A counter to count to 10 (i.e., to keep track of how many numbers have been input and to determine when all 10 numbers have been processed).

b) number: The integer most recently input by the user.

c) largest: The largest number found so far.

This is what I have so far:

class Screen

 def cls

   puts (“n” * 25)

   puts “a”

 end

 def pause

    STDIN.gets

 end

end

class Program

 def display_instructions

   Console_Screen.cls

   puts “INSTRUCTIONS:nn”

   puts “Enter 10 numbers for the program to choose the largest

     one.”

   print “Press Enter to continue.”

   Console_Screen.pause

 end

 def get_numbers

   numbers = []

   $counter = 0

   $number = numbers.last

   $largest = numbers.max

     Console_Screen.cls

     print “nPlease enter a number and press Enter. “

     input = STDIN.gets

     input.chop!

    while counter < 10

      print “last number entered is: #{$number} “

      print “The largest number entered is: #{$largest}”

      if counter < 10

        print %Q{Type a number. (Press Enter)nn: }

        input = STDIN.gets

        numbers.push = input

        $counter += 1

      else counter >= 10

        puts “The End.” 

      end

    end

 end

end

________________________

Could you please help me out?

Thank you.

 
"Not answered?"
Get the Answer