PLEASE USE setfill() and setw() !!!!! The learning objective of this programming assignment is to 1) Improve your skills reg" style="box-sizing: inherit; display: block; margin: 0.5rem 0; height: auto...



PLEASE USE setfill() and setw() !!!!!



Programming Assigment 1: The Pine Tree<br>The learning objective of this programming assignment is to<br>1) Improve your skills reg




You can change the frame character to see a different frame:<br>Program 1: The Pine Tree<br>Choose from the following options:<br>1. D




The second part of the code prints a pine tree. Our pine tree has a layered crown and a trunk. All parts of the tree depends



The top layer of the tree has three rows of stars, \( { }^{\prime *} \) , formatted as the above picture. The trunk is cente



Program 1: The Pine Tree<br>Choose from the following options:<br>1. Display the HELLO graphic<br>2. Display The Pine Tree<br>3. Exit the


#include    // for cin and cout
#include // for setw. The number in setw(...) is the total of blank spaces including the printed item.


using namespace std; // so that we don't need to preface every cin and cout with std::


int main()
{

// Display the menu and get the user choice

int menu_option = 0;

cout < "program="" 1:="" the="" pine="" tree="">

< "choose="" from="" the="" following="" options:="">

< "="" 1.="" display="" the="" hello="" graphic="">

< "="" 2.="" display="" the="" pine="" tree="">

< "="" 3.="" exit="" the="" program="">

< "your="" choice="" -=""> ";

cin >> menu_option;



if (menu_option == 3) { // Handle menu option of 3 to exit

exit(0); // The call to exit the code successfully (0 means the runs didn't encounter any problem).


}



else if (menu_option == 1) { // Handle menu option of 1 to display custom ASCII graphics

// Display ASCII graphics for "HELLO".


// The main purpose of this part is to give you hints about usnig setw and setfill and their behaviors.



//the character for the frame of our display.

char frame = '-';

cout < "enter="" your="" frame="" character:="">

cin >> frame;


cout <>

// The goal of next three lines is to print a line with 77 dashes differently.


cout < setfill(frame);="" change="" the="" default="" character="" for="" filling="" the="" fields="" defined="" using="" setw.="" you="" can="" change="" it="" fill="" to="" different="" character="" to="" see="" the="">

cout < setw(78)="">< "\n";="" \n="" counts="" in="" 78="" so="" you="" will="" get="" 77="" dashes="" plus="" one="">


cout < setw(78)="">< endl;="" after="" setfill="" you="" need="" to="" pass="" a="" string="" or="" character="" to="" push="" setfil="" to="" fill="" the="" field,="" otherwise="" you="" will="" see="" an="" empty="" line="" for="" this="" instruction.="" see="" the="" differnce="" in="" output="" from="" this="" line="" and="" the="" above="">


cout < setw(77)="">< frame="">< endl;="" i="" use="" 77="" with="" setfill="" and="" one="" extra="" at="" the="" end="" to="" get="" the="" same="">



cout < setw(8)="">< "="" "="">< "="" **="" **="" ********="" **="" **="" ********="" "="">< setw(9)=""><>

cout < setw(8)="">< "="" "="">< "="" **="" **="" ********="" **="" **="" ********="" "="">< setw(9)=""><>

cout < setw(8)="">< "="" "="">< "="" **="" **="" **="" **="" **="" **="" **="" "="">< setw(9)=""><>

cout < setw(8)="">< "="" "="">< "="" ********="" ********="" **="" **="" **="" **="" "="">< setw(9)=""><>

cout < setw(8)="">< "="" "="">< "="" ********="" ********="" **="" **="" **="" **="" "="">< setw(9)=""><>

cout < setw(8)="">< "="" "="">< "="" **="" **="" **="" **="" **="" **="" **="" "="">< setw(9)=""><>

cout < setw(8)="">< "="" "="">< "="" **="" **="" ********="" ********="" ********="" ********="" "="">< setw(9)=""><>

cout < setw(8)="">< "="" "="">< "="" **="" **="" ********="" ********="" ********="" ********="" "="">< setw(9)=""><>

cout < setw(77)="">< frame="">< endl;="" the="" extra="" character="" is="" -="" so="" in="" total="" we="" will="" have="" 77="">

cout < setw(78)="">< "\n";="" again,="" the="" extra="" character="" is="" \n="" so="" you="" have="" set="" the="" width="" to="">




//you can do it this way using a for-loop too


for (int i = 0; i < 77;="" i++)="">

cout <>

}

cout <>







} else if (menu_option == 2) {

// Prompt for and get the number of layers for the tree.

int number_of_tree_layers = 0;

cout < "number="" of="" tree="" layers="" -=""> ";

cin >> number_of_tree_layers;



cout < endl;="" do="" not="" remove="" this="" line.="" it="" is="" essential="" for="" the="">








/***********************

*

* REPLACE ME WITH YOUR CODE

*

* *********************/



} //end if( menu_option == 2)





cout < endl;="" do="" not="" change="" this="">



return 0;
}


/******************************************END*******************************************/




PLEASE USE setfill() and setw() !!!!!

Sep 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here