Question: Using Java This program will print output based on two integer inputs and a string input provided by the user. The order and text of

Using Java Using Java This program will print output based on two integer

This program will print output based on two integer inputs and a string input provided by the user. The order and text of the prompts can be derived from the sample runs of the program provided below. As for the logic, if either (or both) of the integers are non- positive, if the integers have the same parity (i.e. both are odd or both are even), or if the string provided is quiz, simply display the output Bad input. Otherwise, calculate the sum, difference, and product of the integers. If any of the calculated values equal 131, simply display the output CMSC131. If all three calculated values are different than 131, you will output the concatenation of the input string and the 3 calculated values. The format of the concatenation will be the input string followed by the sum, difference and product if the length of the input string is less than or equal to 5. If the length of the input string is greater than 5, the format of the concatenation will be the sum, difference (i.e. numl-num2), product, and finally the input string. In both concatenation scenario, an & will be used to separate the 4 output values (see sample output for examples). Finally, remember that you can use the length method of the String to help you develop this program. Sample run #1 Enter num1: 5 Enter num2: 15 Enter word: books Bad input Sample run #2 Enter num1: 76 Enter num2: 55 Enter word: apple CMSC131 Sample run #3 Enter num1: 10 Enter num2: 7 Enter word: bug bug&17&3&70 Sample run #4 Enter num1: 15 Enter num2: 20 Enter word: rhinoceros 35&-5&300&rhinoceros

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!