Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Question regarding output format: Having issues getting the proper output format with my code. It needs to display the countdown on a new line

C++ Question regarding output format:

Having issues getting the proper output format with my code. It needs to display the countdown on a new line if a number over 1 is entered the first sequence displayed in Diff1. But for instances where a number less than 1 is entered, I need the output to remain on one line with no new line break exemplified in Diff4. I've also attached our assignment information and my current code.

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

Overview For this daily, write a program that will display values counting down from N through 1 , inclusive, on one line. A CPP file (countdown.cpp) has been provided. It contains the declaration for an integer variable (N) and code that will ask the user to enter an integer value. Add code that will check the N value for validity. To be valid, the N value must be greater than or equal to 1 . If an invalid N value is entered, display an error message and ask the user for a new N value. This should continue until a valid N value is entered. The error message displayed to the user MUST match the message that is displayed in the output below. Once a valid N value has been entered, write a loop that will display the values N through 1 on one line. Each value should be displayed right justified in a field that is three (3) spaces wide. Print a new line before the loop that displays the values N through 1 and at the end of the output. File You Must Submit Place the completed program code in a source file named countdown.cpp Output The output that is produced by the program will vary based on the values that are entered when the program is executed. The output that is shown below is what the program will produce when it is run in an environment such as Dev C++ or XCode. When it is run through the Auto Grader, the portion that asks for the integer value and the error WILL NOT show the value that is entered. This is used to produce the output for diff 1 : N value (must be greater than or equal to 1) ? 15 151413121110987654321 This is used to produce the output for diff 4: N value (must be greater than or equal to 1) ? 0 Error: the N-value must be greater than or equal to 1 . Try again: 9 Error: the N-value must be greater than or equal to 1 . Try again: 6 Error: the N-value must be greater than or equal to 1 . Try again: 0 Error: the N-value must be greater than or equal to 1 . Try again: 10 10987654321 Output for diff 1: stdout Expected output: 10987654321 Your output: N value (must be greater than or equal to 1)? Differences: 1,2c1,2 <>

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

Students also viewed these Databases questions

Question

2. How does communication shape cultures and social communities?

Answered: 1 week ago

Question

Knowledge of process documentation (process flow charting)

Answered: 1 week ago