Question
The following program, write the code in C++, please do it well, make sure you show all steps and how you did it. Please make
The following program, write the code in C++, please do it well, make sure you show all steps and how you did it. Please make the code such that I can copy paste it. Also please show the output as well, as sometimes the code is given but there is not a correct output, so show a screenshot of your output and that it matches everything asked in the question.
The following is the introduction to the assignment that is required for various tasks but you only have to do the last right now. I have already done the other tasks, so I will send the files and for this you have to build on the code and add on the files for the codes for tasks. You have to do lower.cpp/lower.h and upper.cpp/upper.h but i will send the cpp and header files for the first 3 tasks just so you have an idea of how it should look like, and you should add the functions to the main.cpp for those 2. You have to add the functions for these codes for it to run and compile. The codes for task d and e should be added to it. Please follow all these directions, and make sure all files that I have sent the code of are present and list the names of the files you have and the code for it
This is the intro to the assignment:
For this assignment, you will have to create a Makefile to build your project. It should create a single executable named main.
The main function should call all the functions that accomplish the tasks. Those functions may not be written in main.cpp but rather you should create at least one additional .cpp/.h file(s).
Write a function for each of the tasks. The functions should accept parameters for the assorted dimensions and should return a std::string with a string representing the output. Recall that you can embed a newline in a string to move to the next line.
The main function should call each task function one or more times and print out the results to show that everything works.
For example, for task A you might write a routine with a prototype std::string box(int width, int height).
You might test it from main as follows:
Note: Remember that your program should not ask for any keyboard input. When run it should clearly show that all tasks are implemented and work.
IMPORTANT: NO USER/KEYBOARD INPUT, REMEMBER THAT WHEN MAKING THE CODE
These are the instructions for task a, b, and c that i have done and with the code beneath:
Following all directions above, this is the three tasks hat I have completed and I will send the code I did for this task:
This is my code, with the name of the files listed, the code of the files and the output, (look at all this carefully, this is the platform you will make the codes for task d for)
Makefile:
CXX = g++
CXXFLAGS = -std=c++11
OBJS = main.o box.o
all: main
main: $(OBJS)
$(CXX) $(CXXFLAGS) -o main $(OBJS)
main.o: main.cpp box.h
$(CXX) $(CXXFLAGS) -c main.cpp
box.o: box.cpp box.h
$(CXX) $(CXXFLAGS) -c box.cpp
clean:
rm -f $(OBJS) main
Main.cpp:
#include
#include "box.h"
#include "checkerboard.h"
#include "cross.h"
int main()
{
//Task A: box
std::string result;
result = box(6, 5);
std::cout
std::cout
std::cout
//Task B: checkerboard
std::cout
result = checkerboard(8, 4);
std::cout
std::cout
//Task C: cross
std::cout
result = cross(9);
std::cout
std::cout
//Task D Function here:
//Task E function here:
}
box.cpp:
#include "box.h"
//Task A for box.cpp this is the cpp file, you have to make a cpp file for Task D, "lower.cpp" and a cpp file for Task E, "lower.cpp"
std::string box(int width, int height) {
std::string shape = "";
for (int i = 0; i
for (int j = 0; j
shape += "*";
}
shape += " ";
}
return shape;
}
box.h:
#ifndef BOX_H
#define BOX_H
#include
std::string box(int width, int height);
#endif // BOX_H
checkerboard.cpp:
#include "checkerboard.h"
//Task B for checkerboard.cpp this is the cpp file
std::string checkerboard(int width, int height) {
std::string shape = "";
std::string firstChar = "";
std::string secondChar = "";
// loop to print the characters
for (int row = 0; row
firstChar = " ";
secondChar = "*";
if (row % 2 == 0) {
firstChar = '*';
secondChar = ' ';
}
for (int col = 0; col
if (col % 2 == 0) {
shape += firstChar;
}
else {
shape += secondChar;
}
}
shape += " ";
}
return shape;
}
checkerboard.h:
#ifndef CHECKERBOARD_H
#define CHECKERBOARD_H
#include
std::string checkerboard(int width, int height);
#endif // CHECKERBOARD
cross.cpp:
#include "cross.h"
//Task C for cross.cpp this is the cpp file
std::string cross(int size) {
std::string shape = "";
//std::string line = "";
int counter = 0;
// Loop to print the pattern
for (int i = 0; i
for (int i = 0; i
if ((i == counter) || (i == (size -1 )- counter)) {
shape += "*";
}
else {
shape += " ";
}
}
shape += " ";
counter += 1;
}
return shape;
}
cross.h:
#ifndef CORSS_H
#define CORSS_H
#include
std::string cross(int size);
#endif // CORSS
So as i have cross.h, cross.cpp, etc you have to make files for lower.cpp, lower.h and same for upper.cpp, upper.h, please do it well, and make sure to add the functions for main.cpp
(as said in the comment for main.cpp I made the cpp file for the first task tasks which is the cpp file for these tasks, and then you have to make the task d and e cpp files as i wrote in comments. This is in addition to the functions you add in main.cpp as well as the header files you should make for the functions)
These are the two tasks you have to do for task d and e in which the above directions apply:
Please follow all directions well, make all the files and functions as asked and make sure when ran together it runs, list the name of the files and the code following it beneath when you send it. There should be the makefile that I already have, the updated main.cpp with added functions, and the cpp files for the other tasks and any additional header files needed. Follow all directions well, please.
Overall: the box.cpp, checkerboard.cpp and cross.cpp I made for first 3 tasks is not necessary but the files you should be sending are the updated main.cpp with added functions, the lower.cpp and lower.h and upper.cpp and upper,h. Please send the screenshot of the output as well, so i know it works and make sure the code compiles.
MAKE SURE NO USER INPUT, IT SHOULD BE HARD CODED AS WELL, AND THERE SHOULD BE THE CPP AND HEADER FILES, AS WELL AS THE FUNCTIONS ADDED TO MAIN. FOLLOW ALL DIRECTIONS WELL, AND READ EVERYTHING, URGENT.
// more code up here std::string result; result = box (3,5); std: : cout "box (3,5): "; std: :cout result std: : cout " ------------- "; // seperator // more tests to show that box works fully could be added // more code down here Write a program that asks the user to input width and and prints a solid rectangular box of the requested size using asterisks. Also, print a line between user input and the printed shape (to separate input from output). Example: Input width: 7 Input height: 4 Shape: Write a program checkerboard.cpp that asks the user to input width and and prints a rectangular checkerboard of the requested size using asterisks and spaces (alternating). Example: Input width: 11 Input height: 6 Shape: Write a program that asks the user to input the shape , and prints a diagonal cross of that dimension. Example: Vrite a program lower.cpp that prints the bottom-left half of a square, given the side xample: Input side length: 6 Shape: Task E. Upper triangle Write a program upper.cpp that prints the top-right half of a square, given the side length . Example: Input side length: 5 ShapeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started