Question

Output the following results using ​quote​ variable in the Scala REPL: Quote: "This is homework -...

Output the following results using ​quote​ variable in the Scala REPL:

Quote: "This is homework - and it is hard! We will learn a lot in this course."

  1. Number of non-capitalized words. ​Hint:​ split along spaces to get a new collection.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
// Declare the Quote variable scala> val Quote= "This is homework - and it is hard! We will learn a lot in this course." // split the string using split(" ") method . It will give us array of strings scala> val qteArr:Array[String]=Quote.split(" ") scala> var count =0 // in for loop iterate over array & check each string for Uppercase scala> for(i <- 0 until qteArr.length) | { | val bUpper= qteArr(i).exists(_.isUpper) | if (bUpper == false) | { | count += 1 | } | } scala> println(count)

scala repl screen :

Add a comment
Know the answer?
Add Answer to:
Output the following results using ​quote​ variable in the Scala REPL: Quote: "This is homework -...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT