Creating a simple table

Hello everyone.

I am new to C++ and learning it for the first time with the help of some free C++ tutorial videos from Udemy. I have been trying to create a simple table for the past hour but I just can't figure out what to do.

The table I want to create using the follow input data:

[Name] [Age] [Salary]

John___30____ $300
David__ 42 ____$200
Kat____24____$100

Tax deduction = Salary * 30%

Output to a simple table showing:

[Name] [Tax deduction]

John __________?
David__________?
Kat____________ ?




I have only been able to print the names,ages and salary along with the taxable deduction amount but I haven't been able to turn it into a simple table. I'm not sure what to do, can someone please help me?

Thank you very much in advance
Last edited on
Somethig like that:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <iomanip>

int main()
{
	using std::setw;
	std::cout << std::left;
	std::cout <<
	    setw(7) << "[Name]" << setw(6) << "[Age]" << setw(9) << "[Salary]" << '\n' <<
	    setw(7) << "John"   << setw(6) << "30"    << setw(9) << "$300"     << '\n' <<
	    setw(7) << "David"  << setw(6) << "42"    << setw(9) << "$200"     << '\n' <<
	    setw(7) << "John"   << setw(6) << "24"    << setw(9) << "$100"     << '\n';
}
[Name] [Age] [Salary]
John   30    $300
David  42    $200
John   24    $100
http://en.cppreference.com/w/cpp/io/manip/left
http://en.cppreference.com/w/cpp/io/manip/setw
Last edited on
Topic archived. No new replies allowed.