How to resolve the algorithm The Name Game step by step in the PowerShell programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm The Name Game step by step in the PowerShell programming language

Table of Contents

Problem Statement

Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".

The regular verse Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules. The verse for the name 'Gary' would be like this: At the end of every line, the name gets repeated without the first letter: Gary becomes ary If we take (X) as the full name (Gary) and (Y) as the name without the first letter (ary) the verse would look like this: Vowel as first letter of the name If you have a vowel as the first letter of your name (e.g. Earl) you do not truncate the name. The verse looks like this: 'B', 'F' or 'M' as first letter of the name In case of a 'B', an 'F' or an 'M' (e.g. Billy, Felix, Mary) there is a special rule. The line which would 'rebuild' the name (e.g. bo-billy) is sung without the first letter of the name. The verse for the name Billy looks like this: For the name 'Felix', this would be right:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm The Name Game step by step in the PowerShell programming language

Source code in the powershell programming language

## Clear Host from old Ouput
Clear-Host

$Name = Read-Host "Please enter your name"
$Char = ($name.ToUpper())[0]
IF (($Char -eq "A") -or ($Char -eq "E") -or ($Char -eq "I") -or ($Char -eq "O") -or ($Char -eq "U"))
  {
    Write-Host "$Name, $Name, bo-b$($Name.ToLower())"
  }
else
  {
    IF ($Char -eq "B")
      {
        Write-Host "$Name, $Name, bo-$($Name.Substring(1))" 
      }
    else
      {
        Write-Host "$Name, $Name, bo-b$($Name.Substring(1))"        
      }     
  }

  IF (($Char -eq "A") -or ($Char -eq "E") -or ($Char -eq "I") -or ($Char -eq "O") -or ($Char -eq "U"))
  {
    Write-Host "Banana-fana fo-f$($Name.ToLower())"
  }
else
  {
    IF ($Char -eq "F")
      {
        Write-Host "Banana-fana fo-$($Name.Substring(1))" 
      }
    else
      {
        Write-Host "Banana-fana fo-f$($Name.Substring(1))"        
      } 
  }

  IF (($Name[0] -eq "A") -or ($Name[0] -eq "E") -or ($Name[0] -eq "I") -or ($Name[0] -eq "O") -or ($Name[0] -eq "U"))
  {
    Write-Host "Fee-fi-mo-m$($Name.tolower())"
  }
else
  {
    IF ($Char -eq "M")
      {
        Write-Host "Fee-fi-mo-$($Name.Substring(1))" 
      }
    else
      {
        Write-Host "Fee-fi-mo-m$($Name.Substring(1))"        
      }
  }
Write-Host "$Name"


  

You may also check:How to resolve the algorithm Sieve of Eratosthenes step by step in the GAP programming language
You may also check:How to resolve the algorithm Enumerations step by step in the Oz programming language
You may also check:How to resolve the algorithm Copy a string step by step in the Ol programming language
You may also check:How to resolve the algorithm 100 doors step by step in the Isabelle programming language
You may also check:How to resolve the algorithm Memory allocation step by step in the Nanoquery programming language