Question

Write a ruby algorithm that prints only words that begin with a capital letter Input a...

Write a ruby algorithm that prints only words that begin with a capital letter

Input

a = ['aA', 'Aa', 'red', 'Book']

Output

b = ['Aa', 'Book']

Homework Answers

Answer #1

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.

code screen shot

copy to code

main.rb

#initialize the array
array = ['aA', 'Aa', 'red', 'Book']

#loop for each element in the array
array.each do |i|
  
#now check if first character is same as upper case of it
if i[0]==i[0].upcase
  
#if yes print it
puts i

#end of if condition
end
  
#end of array loop
end

output

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a function that accepts a line of text and a single letter as input (case...
Write a function that accepts a line of text and a single letter as input (case insensitive) and returns the number of times the letter is the first character of a word. Note your program should be able to handle different cases. And check if the user input is a single letter. Example: Input text = "When the SUN rises at dawn, the chicken flies into the window." Input letter = "t" Output = "The letter t has appeared 3...
Write a alogorithem for delete a max heap tree. . Give an efficient algorithm for the...
Write a alogorithem for delete a max heap tree. . Give an efficient algorithm for the following problem. Tree-Successor • Input: A BST T and a node a of T • Output: The node b of T containing the smallest key larger than a.key. If there is no such b, the output should be NIL.
Create program that sorts words of a string based on first letter of each word. Use...
Create program that sorts words of a string based on first letter of each word. Use C programming language. - Only use stdio.h and string.h - Remove any newline \n from input string - Use insert function - Input prompt should say "Enter string of your choice: " - Output should print sorted string on new line Example:     Enter string of your choice: this is a string     a is string this
Write a Python script that asks the user for their Scrabble rack and prints all valid...
Write a Python script that asks the user for their Scrabble rack and prints all valid Scrabble words that can be constructed from that rack, along with their Scrabble scores, sorted by score. An example input and output: ZAEFIEE 17 feeze 17 feaze 16 faze 15 fiz 15 fez 12 zee 12 zea 11 za 6 fie 6 fee 6 fae 5 if 5 fe 5 fa 5 ef 2 ee 2 ea 2 ai 2 ae
Write a two to three page double-spaced (minimum of 500-750 words) letter to the editor, proposing...
Write a two to three page double-spaced (minimum of 500-750 words) letter to the editor, proposing a solution to a current local problem. List the newspaper to which you would be sending this to at the top of your paper. Begin the letter with: "Dear Editor," Throughout the paper, be as specific as you possibly can in terms of: 1.) Defining/describing the problem and who it affects 2.) Describing your solution 3.) Defending your solution as the best means of...
a) How many four-letter words can be formed from the letters of the word TAUDRY if...
a) How many four-letter words can be formed from the letters of the word TAUDRY if each letter can only be used one time in a word? Y is NOT considered a vowel in this word. b) How many contain the letter Y? c) How many contain all the vowels? d) How many contain exactly three consonants? e) How many of them begin and end in a consonant? f) How. many begin with a D and end in a vowel...
**C code only In this part, you will write a simple user-defined function that prints a...
**C code only In this part, you will write a simple user-defined function that prints a message. This function does not require any parameters or return value. The purpose is simply to get you started writing functions.Open repl project Lab: User-Defined Functions 1. Write a program that calls a function. This function should do the following: 1.Ask the user their name 2. Print a "hello" message that includes the user's name Example output: Please enter your name: ​Mat Hello, Mat!...
a) How many four-letter words can be formed from the letters of the word TAUDRY if...
a) How many four-letter words can be formed from the letters of the word TAUDRY if each letter can only be used one time in a word? Y is NOT considered a vowel in this word. b) How many contain all the vowels? c) How many contain exactly three consonants? d) How many of them begin and end in a consonant? e) How many contain both D and Y?
(a) Write an algorithm (use pseudo-code) to determine whether a function f ∶ Z100 → Z100...
(a) Write an algorithm (use pseudo-code) to determine whether a function f ∶ Z100 → Z100 is surjective. That is, supply a “Method” to go with Input: A function (array) f with f(i) ∈ Z100 for i = 0, 1, . . . , 99. Output: Boolean B. B=‘true’ if f is surjective, ‘false’ otherwise. Try to make your algorithm as efficient as possible. Do NOT include an implementation of your algorithm in a programming language. (b) How many comparisons...
Write a Java program to display a letter grade based on an actual grade. A =...
Write a Java program to display a letter grade based on an actual grade. A = 90-100 B = 80-89 C = 70-79 D = 60-69 F = less than 60 The program needs to do the following: 1. Create a short integer to store a grade. (See Week 3 - Things to Know - Java Data Types ) 2. Prompt for a grade ( 0-100). 3. Based on the grade given, use IF statements to display the letter grade...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT