Transcribed TextTranscribed Text

Question 1: Write a program that, prints a 'pine tree' consisting of triangles of increasing sizes, filled with a character (cg. or '+' or '$' etc). Your program should interact withthe user to read the number of triangles in the tree and the character filling the tree. Your implementation should include the following functions: a. void printShi ftedTriangle (int n, int m, char symbol) It prints an n-line triangle, filled with symbol characters, shifted m spaces from the left margin. For example, if we call printShi ftedTriangle (3, 4, ++`), the expected output is: + +++ Left morgin F++++ spaces b. void printPineTree (int n, char symbol) It prints a sequence of n triangles of increasing sizes (the smallest triangle is a 2-line triangle), which form the shape of a pine tree. The triangles are filled with the symbol character. For example, if we call printPineTree (3, # `), the expected output is: # ### # ### ##### Left # morgin ### ##### A++AA## Question 2: a. Implement a function: int printMonthCal ender (int numOfDays, int startingDay) This function is given two parameters: numOfDays The number of days in the month startingDay a number 1-7 that represents the day in the week of the first day in that month (1 for Monday, 2 for Tuesday, 3 for Wednesday, etc.). The function should: Print a formatted monthly calendar of that month Return a number 1-7 that represents the day in the week of the last day in that month. Formatting Notes: The output should include a header line with the days' names. Columns should be spaced by a Tab. Example: when calling printMonthCal ender (31, 4) it should return 6, and should print: Mon Tue Wed Thr Fri Sat Sun 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 b. A method for determining if a year is a leap year in the Gregorian calendar system is to check if it is divisible by 4 but not by 100, unless it is also divisible by 400. For example, 1896, 1904, and 2000 were leap years but 1900 was not. Write a function that takes in a year as input and return true ifthe year is a leap year, return false otherwise. c. Implement a function: void pri ntYearCa: Lender (int year, int startingDay) This function is given two parameters: year an integer that represents a year (e.g. 2016) rtingDay -a number 1-7 that represents the day in the week of 1/1 in that year (1 for Monday, 2 for Tuesday, 3 for Wednesday, etc.). The function should use the functions from sections (a) and (b) in order to print a formatted yearly calendar of that year.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <cstdlib>
#include <iostream>
using namespace std;

void printShiftedTriangle( int n, int m, char symbol){
    for (int i = 0; i < n; i++) {      
       //from the left margin
       for (int j = 0; j < m; j++) {
            cout << " ";
       // from the left side
       for (int k = 0; k < n - i - 1; k++) {
            cout << " ";
       // draw symbol
       for (int k = 0; k < 2 * i + 1; k++) {            
            cout << symbol;
       cout << "\n";

By purchasing this solution you'll be able to access the following files:
Solution1.cpp and Solution2.cpp.

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats