Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I NEED C# PROGRAM PLEASE Objectives Learn the basics of recursion. Background There are many problems that loops simplify, such as displaying every pixel to

I NEED C# PROGRAM PLEASE

Objectives

  • Learn the basics of recursion.

Background

There are many problems that loops simplify, such as displaying every pixel to a screen or receiving repetitive input. However, some situations that can be simplified with looping are not easily solvable using loops. This includes problems that require back tracking and being able to use information from previous iterations, which would normally be lost when using an iterative loop. In those cases, it is much easier to use recursion to logically solve the problem and it may even reduce the amount of code that needs to be written.

Tasks

This lab has two parts:

  1. Write a recursive method that determines how many vowels are in a string.
  2. Print out the results after testing your method on a few different strings.

Task 1 Recursive Method

Create a recursive method, a method that calls itself, that returns the number of vowels that appear in any string given. Keep in mind that we will need to have a base case that will stop the method when it finishes its work (going through the string and counting the vowels).

NOTE: A base case is similar to a loops ending condition. If we dont include one or the condition is never met, then our method will continue to call itself forever just like an infinite loop will continue to run forever.

Task 2 The Driver

Now we just need to call our method from our Main method and test it with a few different inputs (they may be hardcoded or from user input). Print out the results of each of the method calls along with the string that it was searching through.

Some Sample Output:

Checking the number of vowels in "Hello World!, which is: 3

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

More Books

Students also viewed these Databases questions