[ Foro de Java ]

Resolver este ejercicio

23-Nov-2021 13:23
Invitado (Principiante)
0 Respuestas

EXERCISE 7 –Strings
In this assignment, you will create a program that prompts user for a String and then calls a a
number of methods to process the text entered by the user to later inform about the result
through the screen:
Method 1 – parseString
1. If the input has less tan 5 characters, between 5 and 15 characters or more tan 15
characters.
2. If the input starts with ‘a’
For instance, if the input is:
Enter a string: “vereda”
The output should be:
“- The input has between 5 and 15 characters and it does not begin with an ‘a’”
Method 2 – reverseString
Prints the reverse of the String. The output shall look like
For instance, if the input is:
Enter a string: “vereda”
The output should be:
“- The reverse of the string ‘vereda’ is ‘aderev’”
Method 3 – checkVowels
Counts the number of vowels (a, e, i, o, u, A, E, I, O, U) contained in the string, and prints the
count.
For instance, if the input is:
Enter a string: “lorem ipsum 45”
The output should be:
“The input has 4 vowels”
• You could use toLowerCase() to convert the input String to lowercase to reduce the
number of cases to consider.
Method 4 – checkDigits
Counts the number of digits (0-9) contained in the string, and prints the count.
For instance, if the input is:
Enter a string: “lorem ipsum 45”
The output should be:
“The input has 2 digits”
• To check if a char c is a digit, you can use boolean expression (c >= '0' && c <= '9'); or
use built-in boolean function Character.isDigit(c).
Submission Instructions
Once you have finished submit your solution using the Submit button of Codeboard
Testing Instructions
Once you think you have reached a solution, you could try if it works properly without
submitting. To that end, click the Test button shown in the next figure..
As a result, your program will be run with a different number of test inputs, and the system will
inform about the result of those executions, as the following figures illustrate.
First message states that 0 out of the 6 tests run have passed, i.e. the solution has been tried with
different inputs and it has not worked properly. More specifically, if we go through the rest of
the information on the screen dump we can see that errors have been raised when running the
checkDigits() method (2 times), the checkVowels method (2 times) and the reverseString()
method (2 times).
Finally, a new summary states again that 6 tests were run and all of them failed. All this given,
you should check your code before submission to fix existing problems since, apparently, the
solutions you have provided are not working properly.




Si ya eres usuario del sistema, puedes contestar desde tu cuenta y así ganar prestigio.

Si sólo eres un visitante, puedes optar por...