Module 6 SOLUTION

Program description: Starting with your Assignment 5 solution, or if you had issues completing, you can start with the posted module 5 solution, you are going to make modifications to the three features so that they are methods. The program from the user view is unchanged! This program will function exactly as Assignment 5 did, only that instead of features code in the if/else block, there will be methods called to run the features, with modifications to be followed below. The code for feature 1 is to be moved into a newly created method called feature1, feature1 is to be a void method which has no arg value and does not return a value. Literally cut and paste the code within the if block matching to ‘1’ and that code in to be inserted into the new feature1 method, put the feature1 method at the end of the file, outside of the main method block. The code for feature 2 is to be moved into a newly created method called feature2, feature2 is to be a void method ( no return value ) which has one arg value of type int, called count. The code from the feature 2 that prompts the user for the flip value is the passed to the new feature2 method, the remaining code is cut and inserted into the new feature2 method put the feature2 method at the end of the file, outside of the main method block. The code for feature 3 is to be moved into a newly created method called feature3, feature3 is to be a String method ( returns a String ) which has one arg value of type String, called s. The code from the feature 3 that prompts the user for string message is passed to the new feature3 method, the remaining code is cut and inserted into the new feature3 method all but the print statements. The print statement(s) are replaced with a return, and the value for the return is contents of the original print statements which is everything between the parentheses of BOTH print statements. Note you will have to concatenate ( use + ) and add a \n to match the original vowel and constant messages. The else if prints out the returned message by calling feature 3 as shown below: // call the method of feature 3 providing the message s from the user, return // value is the Letters message which is printed to user for the consonants count   System.out.println(feature3(s)); Put the feature3 method at the end of the file, outside of the main method block. Your program is to look exactly like the output shown below, only the name would be different. Notice that an apostrophe is used in the prompt, your program must do the same. The example shows all four possibilities for the program, option 1,2,3 and any other input by the user which would exit the program. Highlight in yellow is user provided input. Tip: You should do this is steps, start with the easiest, which is feature 1 change, when that is completed successfully, the do feature do likewise feature 2 and feature 3. Your textbook as has many example that will show you exactly the required syntax needed to complete this assignment.
Powered by