Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***** I need the java code *** *******please use the eclipse to slove the question ***** String Operations Write a program that prompts for and

***** I need the java code ***

*******please use the eclipse to slove the question *****

image text in transcribedimage text in transcribed

String Operations Write a program that prompts for and reads in a line of text, and then performs the following tasks: Outputs the number of characters on the line. (Hint: The String class has a method named length() that returns the number of characters in a string.) Outputs the number of words on the line. (Hint: Break up the line of text with the method split using 1 or more whitespaces as a delimiter (\\s+"), and then output the size of the returned array.) Outputs the longest word on the line. (Hint: The split method breaks-up the line of text into words (or tokens), and stores those words into an array. Search that array to find out the longest word.) Outputs the words in ascending order. (Hint: The Arrays class has a method named sort that takes an array as an argument, and orders the elements of that array in ascending order.) Include a loop in the program that allows the user to repeat the above steps as often as (s)he/they wishes. Sample Input and Output: Programmer: Course: Lab#: Due date: Name of the programmer (your name) COSC 211, W22 2, part 1 1-27-2022 Enter a line of text: Hello to all Number of characters: 12 Number of words: 3 Longest word: Hello Words in ascending order: Hello all to Do it again, yes (or no)? Yes Enter a line of text: The fat cat sat on the mat in front of the door Number of characters: 47 Number of words: 12 Longest word: front Words in ascending order: The cat door fat front in mat of on sat the the Do it again, yes (or no)? no Prime Numbers A number is prime if it has no divisor other than 1 and itself (see pages 191-192 of your textbook, and demo011822 from the class website). A prime number that can be written in the form of 2P 1 for some positive integer p is known as Mersenne prime (Google it if you want to learn more about Mersenne primes). Write a method named 'isPrime that takes a BigInteger as an argument and determines whether or not that BigInteger value is a prime number. The method returns true if the number is a prime, and false otherwise (see method primeBig in demo011822). public static boolean is Prime (BigInteger num) { } Write a program (a main method) that finds all Mersenne primes with p

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_2

Step: 3

blur-text-image_3

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

Has the priority order been provided by someone else?

Answered: 1 week ago

Question

Compare the current team to the ideal team.

Answered: 1 week ago

Question

Are the rules readily available?

Answered: 1 week ago