Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ please All Lab and Project assignments must be accomplished solely by you: - Abide by the University code of student conduct. - DO NOT

C++ please

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

All Lab and Project assignments must be accomplished solely by you: - Abide by the University code of student conduct. - DO NOT look at anyone's code other than your own, including code from another student in your section or another section of the course, or any third party source, e.g. the Internet. - DO NOT share or copy anyone else's code for any graded assignment. Do not post the assignment nor your solution ANYWHERE. - DO NOT work in pairs or groups. - Any violation of the above and statements in the syllabus will result in a report to the Committee On Academic Misconduct (COAM). Programming Instructions Write a program that prints inverted trapezoids using the character '-'. The user will enter the number of '-' characters on the first row and then the number of rows forming the trapezoid. For instance, an inverted trapezoid with 7 '-' characters in the first row and 3 rows forming the inverted trapezoid looks like: No row is allowed to have less than two '-' characters. You will write code to check for this. Determine the appropriate loop(s) to use (while loop or for loop) when a task requires looping. Study the tests below to help you understand program behavior. Use the following tests and your own tests to run against your solution in Develop mode. These are the same tests that your solution will be executed against when you submit your work in Submit mode. User input is in bold: Sample Runs (Program Behavior) User in put is in bold: Test 1 > run Enter size of top: 1 Size of top row must be at least two. Enter size of top: 0 size of top row must be at least two. Enter size of top: 1 Size of top row must be at least two. Enter size of top: 2 Enter number of rows: 1 Test 2 >run Enter size of top: 5 Size of top row must be at least two. Enter size of top: 2 Enter number of rows : 1 Invalid number of rows. Enter number of rows: 0 Invalid number of rows. Enter number of rows: 2 Invalid number of rows. Enter number of rows: 4 Invalid number of rows. Enter number of rows: 1 Test 3 > run Enter size of top: 3 Enter number of rows: 1 Invalid number of rows. Enter number of rows: 0 Invalid number of rows. Enter number of rows: 2 Invalid number of rows. Enter number of rows: 1 Test 4 >run Enter size of top: 4 Enter number of rows: 3 Invalid number of rows. Enter number of rows: 1 Test 5 >run Enter size of top: 4 Enter number of rows: 3 Enter number of rows: 2 Test 6 > run Enter size of top: 5 Enter number of rows: 3 Invalid number of rows. Enter number of rows: 2 Test 7 > run Enter size of top: 10 Enter number of rows: 6 Invalid number of rows. Enter number of rows: 5 Test 8 Test 12 > run Enter size of top: 13 Enter number of rows : 7 Invalid number of rows. Enter number of rows: 6 --_-- Programming Assignment Your solution will be graded based upon program behavior (passing tests). Your solution will not receive full credit (or receives no credit) if you fail to follow these restrictions: - Your program must compile and run. Otherwise it will receive a zero. - Add your solution to the provided code template. - Do NOT use the do-while statement. Only use the while and for statements where appropriate. - Do NOT use the do-while statement. Only use the while and for statements where appropriate. - Use descriptive variable names. Avoid too short variable names, especially single letter variable names. - DO NOT start a variable name with a capital letter. - DO NOT use == true or == false in your boolean expressions (see lecture notes). - DO NOT use explicit type casting. Instead use coercion (see lecture notes). - DO NOT unnecessarily use parenthesis in an expression, e.g. an equation or formula. Parenthesis should only be used for grouping portions of an expression to change operator precedence order. For example, parenthesis are unnecessary in the expression (a+b+ c). Instead use a+b+c. Parenthesis are necessary in the expression (a+b+c)/3. - DO NOT use the break and continue statements in your solution. - Your program must be readable including indenting, spaces, and avoid lines that are too long. Use the the sample programs in the lecture notes as a guide. - Comment your program. Read the document at the "Lecture" link on Carmen under Modules->Commenting Your Program-> Commenting your program. DO NOT comment every line. - Only use C++ statements presented in the course. I.e. statements and notation presented in the lecture notes and assigned readings. To receive full credit, only use C++ statements presented in the lecture notes and assigned readings. Your solution will be graded based on passing test cases, formatting, and good choice of variable names. Write your solution in the provided code template. Important!: Write your code incrementally. This means implement your solution one portion at a time where you compile, run, and test the code portion before moving on to the next portion. Use the provided test cases to help you arrive at your final solution. TASK 1: Study the lecture notes (Powerpoint slides and pre-recorded lectures) and assigned readings before you start. TASK 2: Replace "??" with your name, creation date, and a description of the program (synopsis). NOTE: DO NOT delete nor change the code already given to you in the code template, except for the comment /* INSERT YOUR CODE HERE */. You will insert your solution by replacing /*INSERT YOUR CODE HERE */. TASK 3: Write C++ code to prompt the user for the number of ''' characters on the first row. Repeatedly re-prompt the user if the value entered is not at least two. Compile, run, and test this solution before continuing to the next task. TASK 4: Write C++ code to prompt the user for the total number of rows to display. Repeatedly re-prompt the user if any row would not have at least two '-' characters. TASK 5: Write C++ code to display the inverted trapezoid given the values entered in TASK 3 and TASK 4. - Be sure that there is a comment documenting each variable (see the document on Carmen under Modules on how to comment your code) - Do not start a variable name with a capital letter. Be sure that your code is properly indented, readable, and use good descriptive names. - Test your solution. Program Submission Important: Any program which does not compile and run will receive no credit! If you are not sure what this means please ask your instructor. Submit your work by clicking on the "Submit mode" button and then click on "Submit for grading". Remember that you may submit as many times as you like. Your submission will be executed against provided tests. Your latest submission will be considered the final submission and only that submission will be graded

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

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

Answered: 1 week ago