
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Write in C++. Need help matching the output below

Transcribed Image Text:**Programming Task Instructions**
This task involves writing a complete program with the following steps:
1. **Use a do...while loop to prompt the user for input:**
- The user must enter a count greater than 1 and less than or equal to 20.
- If an invalid input is detected (a count less than or equal to 1, or greater than 20), prompt an error message. Ignore the invalid input and continue prompting the user until a valid number is entered.
2. **Display an upside-down triangle using for loops:**
- Set `amountOfStars` to the number entered from the user's input.
- Output `amountOfStars` stars, followed by a new line for each iteration.
- Decrease `amountOfStars` by one after each line.
- Continue this process until `amountOfStars` is zero, forming an inverted triangle.
3. **Display a right-side-up triangle using while loops:**
- Initialize `amountOfStars` as 1.
- Output `amountOfStars` stars, followed by a new line for each iteration.
- Increase `amountOfStars` by one after each line.
- Continue this process until `amountOfStars` is equal to the number entered initially by the user.
**Error Handling:**
- The program should manage situations where a user inputs an invalid character or an out-of-bounds number. In these cases, clear the stream, discard previous invalid inputs, show an error, and re-prompt the user. Ensure valid values are entered before proceeding with the program logic.
**Loop Requirements:**
- A do...while loop is mandated for obtaining user input.
- A for loop must be employed for creating the first triangle.
- A while loop is necessary for forming the second triangle.
- Adherence to these loop structures is critical for successful completion of the lab task. Failure to comply results in a score of zero for this lab exercise.

Transcribed Image Text:### Transcription of Image for Educational Purposes
This text seems to represent a program output that prompts users to enter a count within a specific range. Here's the transcription and explanation:
#### Text Output
```
Enter a count between 2 and 20
**failed
Error: Invalid entry, please retry
Enter a count between 2 and 20
**whoops
Error: Invalid entry, please retry
Enter a count between 2 and 20
**!
Error: Invalid entry, please retry
Enter a count between 2 and 20
**hello
Error: Invalid entry, please retry
Enter a count between 2 and 20
**6
******
*****
****
***
**
*
*
**
***
****
*****
******
```
#### Explanation
The text consists of several prompts and responses:
1. **Prompts and Errors:**
- The program repeatedly prompts, "Enter a count between 2 and 20".
- Multiple invalid entries are attempted (e.g., "failed", "whoops", "!", "hello") and generate the error message: "Error: Invalid entry, please retry".
2. **Valid Entry:**
- A valid entry of `6` is entered.
- This results in a pattern of asterisks being displayed. The pattern starts with six asterisks and reduces by one asterisk per line until it reaches a single asterisk. Then, it mirrors back up to six asterisks.
#### Diagram Explanation
- **Asterisk Pattern:** The asterisk pattern resembles an inverted pyramid transitioning into an upright pyramid:
- Descends from `******` to `*` and ascends back to `******`.
- Demonstrates the program responding to valid input by generating a symmetrical pattern based on the user-entered number.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images

Knowledge Booster
Similar questions
- Answer in c++arrow_forwardThis is very helpful thank you. If possible can you please show me how to make the function with the original parameters C++arrow_forwardPlease use C++ and only use header<iostream>. Any others will not be accepted. Hint included from for assignment. Thank you!arrow_forward
- Write a function in C++ that accepts a single number, calculates the number of positive odd numbers below the parameter value and returns the calculated result to the main method.arrow_forwardplease code this for me in c++ using void, functions, loops, (basic c++ not complicated or highlevel please). I tried to code it myself but there are many mistakes I dont know how to fix so please write a similar one for me but it works. The question is only 1 but it has 2 parts (2 different functions that should be in one code) MY CODE: #include <iostream>using namespace std; int IsPalindrome(int p);void GCD(); int main (){ int choice; cout << "Please enter a choice: "<<endl; cout << "Enter one for IsPalindrome "<<endl; cout << "Enter 2 for GCD "<<endl; cout << "Enter 3 to exit the program "<<endl; cout << "Choice: "<<endl; cin >> choice; if (choice == 1) { int p; cout << "Please enter a 3 digit number: "<<endl; cin >> p; if(p%10==p/100) { cout<<p<<" is a palindrome " <<endl; } else {…arrow_forwardProvide full C++ main.cpp, fraction.cpp, fraction.harrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education