Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with my C++ homework Create a program that will prompt the user for the inputs of an arithmetic sequence: The sequence is:

Please help me with my C++ homework

Create a program that will prompt the user for the inputs of an arithmetic sequence: The sequence is: { a, a + d, a + 2d, a + 3d, ... , a + (n 1)d }

Input the values of the arithmetic sequence: The starting value: #a The common difference: #d The number of terms: #n

Using part (1), generate the sequence, print all n values of the arithmetic sequence 10 items per line. You will need a special check if you printed 10 on the same line and if so print a new line.

Using parts (1) and (2) display the sum of the sequence. The output should look like:

 The sequence is: #1, #2, #3, ..., #last The sequence has sum: # 

Test your program with the values (a, d, n) (5, 3, 9), (11, 2, 12), (3, 0, 14), (2, 0.1, 13), (1, -0.3, 41).

Add an OUTER loop to allow the user to continue entering in numbers as long as y or Y is entered after the question:

 Do you want to continue? Type Y or y for yes: # 

Expected output for each of the values required: (Not all values are shown here)

(5, 3, 9): sequence: 5, 8, 11, ..., 29 sum: 153 (11, 2, 12): sequence: 11, 9, 7, ..., -11 sum: 0 (3, 0, 14): sequence: 3, 3, 3, ..., 3 sum: 42 (2, 0.1, 13): sequence: 2, 2.1, 2.2,..., 3.2 sum: 33.8 (1, -0.3, 41): sequence: 1, 0.7, 0.4,..., -11 sum: -205 (-12, 3, 1): sequence: -12 sum: -12 

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

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions