[SOLVED] CS150 Lab 18

25.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (2 votes)

Write a function called treeTop that prints the top of a tree. It should take no parameters and return void. Write a second function called treeTrunk that prints the trunk of a tree. It should take one integer as a parameter for height (how many lines tall the trunk is), and also have a return type of void. Finally, create a function called drawTrees that takes two integer parameters, one for height and one for the number of trees to draw. drawTrees should use treeTop and treeTrunk.
Have the user enter the height of the trees (same for all) and number of trees to draw.
Note: The backslash symbol is used for certain special characters in strings in C++, such as (new line) and (tab), as such, to actually draw a single backslash you need two consecutive backslashes \ in your string.
Test cases:
Test case 1:
Enter tree height: <2>
Enter number of trees: <3>
^
/ /
/____
| |
| |
^
/ /
/____
| |
| |
^
/ /
/____
| |
| |
Test case 2:
Enter tree height: <5>
Enter number of trees: <1>
^
/ /
/____
| |
| |
| |
| |
| |

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.