Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can I write this code in C++? The purpose of this programming project is to write a C++ program that uses programmer-de ned functions

How can I write this code in C++?

The purpose of this programming project is to write a C++ program that uses programmer-de ned functions to validate user input, calculate some results, and then print out a triangle shape to the screen based on input from the user. Please do not use global variables, or go to statements.

image text in transcribed

.You will first prompt the user to enter an even integer between 2 and 12 inclusively. You will validate the user's input by creating a programmer- defined function to ensure that the integer is an even integer in the range 2 to 12, inclusively. The integer entered by the user should be passed as a parameter to this function. If the number is not valid, you will display a meaningful error message before re-prompting the user to enter the integer again. The return type of this function should be a boolean data type and you are to use this boolean result in determining whether or not the user input is valid. You may assume that the user enters an integer, though it may be out of range Once validated, you will calculate and return the product of the integers from 1 to the integer entered by the user using another programmer defined function. Again, the integer entered by the user should be passed as a parameter to this function. The return type of this function should be an integer data type and you are to use this integer result and print it to the screen in a meaningful message Finally, you will draw a right-justified right-angled triangle using a programmer-defined function that accepts an integer as a parameter. The integer entered by the user will specify the number of rows of integers that will form the triangle. In other words we may say that this integer entered by the user represents the height of the triangle. Each row in the triangle will be composed of a certain integer number (and space where needed) the topmost row will contain one 1, the second row will contain two 2's, the third will contain three 3's and so on and so forth. You may only use cout statements that print a single integer, space, or a single new-line character (such as '' or endl). Maximize your use of repetition with nested for loops and minimize the number of cout statements. This function should be a void function that does not return a value. It should print a right justified right- angled triangle of the appropriate size entered by the user. See the sample program runs for examples of what should be output

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

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions