Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your assignment is to read Chapter 3 about setw, setfill, left, and right. Then,

ID: 3564909 • Letter: Y

Question

Your assignment is to read Chapter 3 about setw, setfill, left, and right. Then, write a program of your choice which uses all of those features. The program does not need to be long. Just enough code to show me you can use those features in a program. Be creative!

Also, you may not use any of the example code from the book as your program. I want you to write your own code. In Thursday's class, you will use these output manipulators to create another program using files.

I need help in this HW

Thank you

Explanation / Answer

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

int main(){
int time1[] = {4, 48, 4488, 1256489, 12478936};
int time2[] = {8, 16, 922, 4058, 5698741};
std::cout << "size" << std::setw(20) << "time" << std::setw(20) << "time2 ";
std::cout << std::setfill('-') << std::setw(60) << "-" << std::endl;
int run = 10;
std::cout << std::setfill(' '); //fill with spaces
for(int i = 0; i < 5; i++) {
std::cout << std::setw(20) << std::left << run; // fill the run column
run *= 10;
std::cout << std::setw(20) << std::left << time1[i];
std::cout << std::setw(20) << std::left << time2[i] << " ";
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote