Question: Using JAVA Your task is to prompt the user for 4 values (see sample runs for the prompt). The first value is where the sequence

Using JAVA Using JAVA Your task is to prompt the user for 4 values(see sample runs for the prompt). The first value is where thesequence starts, the second value is the number of terms, the third

Your task is to prompt the user for 4 values (see sample runs for the prompt). The first value is where the sequence starts, the second value is the number of terms, the third value is the common difference between the terms, and the fourth value is a single character. Assume all numeric inputs will be integers and the user will provide a single character for the fourth input. There are 3 possible results that can be generated by this program 1. If any of the three numeric inputs is not positive, the program simply prints Bad input. See Sample run #1. 2. If the symbol entered is $, the program will print the sequence backwards (i.e. last term first and the first term last). See Sample run #2. 3. If the symbol entered is anything other than $, your code should produce a rectangle of outputs with number of terms rows and number of terms + 1 columns. The word output is defined to be either a number (e.g. 90) or a symbol (e.g. &). In each row of your rectangle, you will print out the next number in the sequence. Starting with second row and onwards, you will print out the sum of terms in the row after printing out all the terms for that row. If you have less than terms + 1 outputs on a row, you use the user supplied symbols (i.e. the fourth input value) to get the terms + 1 outputs needed for each row. Let us look at sample run #5 for an example of what is expected. Notice the program generates the 5 row by 6 column rectangle. Notice how each row has 6 (i.e. 5+1) outputs (i.e. either a number or @). Notice that every row introduce a new term of the sequence. For example, row 2 has the 15, the second term of the arithmetic sequence (starting at 12 with a common difference of 3), and the third row has the 18, the third term. Finally, notice how starting on row 2, the last number that prints out, is the sum of the terms on that row. For example, 27 on row 2 is just 12+15. Likewise, 45 on row 3 is just 12+15+18. 5 5 Sample run #1 Enter start: 12 Enter number of terms: Enter step: -3 Enter symbol: $ Bad input Sample run #2 Enter start: 12 Enter number of terms: Enter step: 3 Enter symbol: $ 24 21 18 15 12 Sample run #3 Sample run #4 Enter start: 12 Enter number of terms: 1 Enter step: 5 Enter symbol: Y 12 Y Enter start: 12 Enter number of terms: 2 Enter step: 5 Enter symbol: % 12 % % 12 17 29 Sample run #5 Enter start: 12 Enter number of terms: 5 Enter step: 3 Enter Symbol: @ 12 @ @ @ @ @ 12 15 27 @ @ @ 12 15 18 45 @ @ 12 15 18 21 66 @ 12 15 18 21 24 90 Sample run #6 Enter start: 17 Enter number of terms: 8 Enter step: 7 Enter symbol: & 17 & & & & & & & & 17 24 41 & & & & & & 17 24 31 72 & & & & & 17 24 31 38 110 & & & & 17 24 31 38 45 155 & & & 17 24 31 38 45 52 207 & & 17 24 31 38 45 52 59 266 & 17 24 31 38 45 52 59 66 332

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!