PLEASE USE setfill() and setw() !!!!!
#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 choiceint 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 exitexit(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 toofor (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*******************************************/
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here