Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Ruby script that will allow a youngster to practice his arithmetic skills. More specifically, your program will allow the user to choose between

image text in transcribed

Write a Ruby script that will allow a youngster to practice his arithmetic skills. More specifically, your program will allow the user to choose between addition, subtraction, multiplication, and division problems. Your program must use at least six functions: o One to display the menu o One to handle addition (In Easy level, generate two random numbers between 0-10, ask the user for the sum, read their answer from the keyboard, compare to see if it was correct, display if they got it right or wrong, and display the correct answer if they got it wrong) o One to handle subtraction (similar to addition, difference will between 0-10 in Easy level) o One to handle multiplication (similar to addition, factors are 0-10 in Easy level) o One to handle division (similar to addition, quotient will be between 0-10 in Easy level....be careful avoiding division by zero!) o One to get the level of difficulty for problems. This function should ask user to enter "E" for easy, M for medium, or D for difficult. The function should loop until a valid choice is entered. Once valid, that letter should be returned. o When the user chooses Quit from the menu, the script should display the number correct, the number attempted, and the percentage correct. o Do not use any global variables. Pass data to functions using parameters where necessary

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

Students also viewed these Databases questions