Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java. Please account for all cases. Thank you. An arithmetie series is just the sum of the terms in your sequence, so for the

image text in transcribed
image text in transcribed
image text in transcribed
In Java. Please account for all cases. Thank you.
An arithmetie series is just the sum of the terms in your sequence, so for the above example, the sum would be 12+15+18+21424 - 90. In general, you can use the formula 2 ant). So for the above sequcnice we have 5 terms (len = 5), the firsten is 12.1 12) and the fifth term is 24 (L.e. -24). Therefore, 52 (1224) - 90 The information above was solely provided so all students have the sume basic knowledge for this quiz. You are not obligated to explicitly use the formulas above in your quiz code. For example, in my solution I do not use the formula 2 (1+1), but instead use my looping construct to iteratively come up with the sum. Your task is to prompt the user tor 4 values (see sumple 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 6 a single character Assume all numeric inputs will be integers and the user will provide a single chunacter 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 S, the program will print the sequence backwards (ie. 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 her after rows and number of forms + 1 columns. The word outpur is defined to be elther a mambet (c.g.90) or a symbol (e.g. 4). In each row of your rectangle, you will print out the next number in the sequence. Starting with second row and cawards, you will print out the sum of terms in the row aller printing out all the terms for that row. If you have less than ferm. 1 outputs on a row, you use the user supplied symbols (i.e. the found input value) to get the terms 1 outputs needed for each row. Let us look at sample rum 5 for an example of what is expected. Notice the program generates the row by 6 column rectangle. Notice how each row has 6 (ie. 5+1) outputs fi.e. either a munber or Notice that every row introduce a new tem of the sequence. For example, tow 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 tow 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 Sample run # Ent start: 12 Enter number of terms: 5 Enter step: Enter symbol: $ Bad input Sample run 2 Enter start: 12 Enter number of terms: 5 Enter step: 3 Enter symbol: $ 24 21 18 15 12 Sample run 3 Enter start: 12 Enter number of terms: 1 Enter step: 5 Enter symbol: Y 12 Y Sample run Enter start: 12 Enter number of terms: 2 Enter step: 5 Enter symbol: 12 % % 12 17 29 For example, the following is an arithmetic sequence with 5 terms where the common difference of 3. 12, 15, 18, 21, 24 I/i.e. 15-12 - 3,18-15-3, and so forth. In general, you can get the nth term (1.e. a) using the formula a. = a +(n-1)d,whered is the common difference and n is the number of terms For the example above, 21 is the 4ter which is 12 +(4-1) 3 -21, and 24 is the term which is 12 +(5-1)3 - 24 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

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

Prepare an ID card of the continent Antarctica?

Answered: 1 week ago

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago

Question

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

Answered: 1 week ago