Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 Javaimage text in transcribed

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

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

Step: 3

blur-text-image

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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago