PLEASE I NEED C# PROGRAM WITH DETAILS
Objectives
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:
Task 1 – Recursive Method
Create a recursive method, a method that calls itself, that returns true or false depending on whether or not a given string is a palindrome. A palindrome is a word that reads the same forwards and backwards, such as “tacocat”.
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:
Received “tacocat” which is indeed a palindrome.
Received “lol” which is indeed a palindrome.
Received “haha” which is indeed a palindrome.
Received “catermelon” which is not a palindrome.
using System;
class Program
{
//method to print the output to a console which calls the method
Palindrome
static void print_output(string input)
{
if(Palindrome(input))
{
Console.WriteLine("Recieved {0} which is indeed a Palindrome",
input);
}
else
{
Console.WriteLine("Recieved {0} which is not a Palindrome",
input);
}
}
//method to check whether a string is palindrome or not
static bool Palindrome(string input)
{
//if input length is less than or equal to 1 it is a
palindrome
if(input.Length <= 1)
{
return true;
}
//check the first and last characters of the string
if(input[0] == input[input.Length - 1])
{
//check for the remaining string except the first and last
characters
return Palindrome(input.Substring(1, input.Length - 2));
}
return false;
}
static void Main() {
//read the input from user and print the output
string input1 = Console.ReadLine();
print_output(input1);
string input2 = Console.ReadLine();
print_output(input2);
string input3 = Console.ReadLine();
print_output(input3);
string input4 = Console.ReadLine();
print_output(input4);
}
}
If you have any doubts please
comment and please don't dislike.
PLEASE I NEED C# PROGRAM WITH DETAILS Objectives Apply recursion to a more difficult problem. Background...
*In JAVA please* Tasks This lab has two parts: Write a recursive method that converts a decimal number to a different base number system. Print out the results after testing your method on a few different inputs. Task 1 – Recursive Method Create a recursive method that returns a given number converted from base ten to a given other base number system ranging from two to thirty-six. A decimal number, or base ten number, can be expressed in any other...
C++ PROGRAM ONLY!
For this lab you need to write a program that will read in two values from a user and output the greatest common divisor (using a recursive implementation of the Euclidean algorithm) to a file. In Lab #3, you implemented this program using an iterative method. Greatest Common Divisor In mathematics, the greatest common divisor (GCD) of two or more integers (when at least one of of them is zero then the larger value is the GCD....
PLEASE I NEED C# Objectives Learn the basics of exception handling. Background Exceptions are essentially unexpected situations. It is difficult to write a program that can handle all possible situations, as we have found out through the many programs we have written. For example, should your program accept accidental input? Does it use the metric system or the empirical system? Do users of your program know which system it uses? In order to deal with all these possibilities, exceptions were...
Assignment 6: Recursion Learning Outcomes • Learn how to craft solutions using recursion instead of loops. Instructions This assignment will be different than previous assignments (and most assignments which come after it). In this assignment, you will be crafting four solutions to four different problems. This assignment will also have special requirements regarding how you may code. You are not allowed to use assignment statements. This includes using preincement, postincrement, predecrement, and postdecrement. You are allowed to use assignment to...
C++ please
Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require that you read in an encrypted message from a file, decode the message, and then output the message to a file. The encryption method being used on the file is called a shift cipher (Info Here). I will provide you with a sample encrypted message, the offset, and the decrypted message for testing. For this project I will provide you main.cpp, ShiftCipher.h, and ShiftCipher.cpp....
In Problem Set 7 you designed and implemented a Message class. This time, let's design and implement a Mailbox class in a file named Mailbox java. Do the following with this class • You may use the Message class from PS 7. You will have to add new features to the Message class from PS 7 as you work through this problem. You are welcome to start with my sample solution if you wish • Suppose there are multiple mail...