Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

plz help me with this using JAVA For example, the following is an arithmetic sequence with 5 terms where the common difference of 3. 12,

plz help me with this using JAVAimage text in transcribedimage text in transcribedimage text in transcribed

For example, the following is an arithmetic sequence with 5 terms where the common difference of 3. 12, 15, 18, 21, 24 l/i.e. 15-12 = 3, 18-15= 3, and so forth. In general, you can get the nth term (i.e. an) using the formula an= a1 +(n - 1)*d, where d is the common difference and n is the number of terms For the example above, 21 is the 4th term which is 12 +(4-1) * 3 = 21, and 24 is the 5th term which is 12 +(5-1) *3 = 24 An arithmetic series is just the sum of the terms in your sequence, so for the above example, the sum would be: 12+15+18+21+24 = 90. In general, you can use the formula n/2 *(a1 + an). So for the above sequence we have 5 terms (i.e. n = 5), the first term is 12 (i.e. a1 = 12) and the fifth term is 24 (i.e. an = 24). Therefore, 5/2 * (12+24) = 90 The information above was solely provided so all students have the same 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 n/2 *ai + an), but instead use my looping construct to iteratively come up with the sum. 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. 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. Sample run #5 Enter start: 12 Enter number of terms: 5 Enter step: 3 Enter symbol: @ 12 @ @ @ @ @ 12 15 27 @ @ @ 12 15 18 45 a a 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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago