Wednesday, July 10, 2019

Power of a Number in Ruby


Design and create a program that will ask the user to give base and exponent values using methods and then the program will compute the power value of the number and then display the result on the screen using Ruby programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com



Sample Program Output


Program Listing

power.rb


# power.rb
# Written By Mr. Jake Rodriguez Pomperada,BSCS,MAED-IT
# Tools : Ruby 2.6.3 and Sublime Text Editor 
# June 17, 2019    Monday   12:12 PM
# Bacolod City, Negros Occidental
# Website       : http://www.jakerpomperada.com
# Email Address : jakerpomperada@gmail.com and jakerpomperada@yahoo.com

def square_solver(base,exponent)
  return(base ** exponent);
end

puts "\n\n"
print "\tPower of a Number";
puts "\n\n"
print "\tEnter a Base Number : ";
base = gets;
print "\tEnter an Exponent   : ";
exponent = gets;

base = base.to_i;
exponent = exponent.to_i;

solve_power = square_solver(base,exponent);

print "\n\n";
print "\tDISPLAY RESULTS";
print "\n\n";
print "\t#{base} ^ #{exponent} = #{solve_power}";
puts "\n\n";
print "\tEnd of Program";
puts "\n";



No comments:

Post a Comment