P03b - Scale Demo |
|
//P03b Scale Display - An Example Juan Marquez TR 1:00pm
/*
This program demonstrates how the \t character aligns to
the preset tab stops.
Each tab is 8 spaces, and the next character is placed in
the 9th position.
After a character is displayed on the 80th position, the
next line is wrapped to the beginning of the next line.
Keep in mind that a newline character is not inserted.
*/
#include <iostream>
using namespace std;
void main()
{
cout << "P03b - Juan Marquez TR 1:00pm \n\n";
//Display scale
cout
<< " 1 2 3 4"
<< " 5 6 7 8" // << endl
<< "1234567890123456789012345678901234567890"
<< "12345678901234567890123456789012345678901234567890"
<< endl
<< "\tx \tx \tx " << "\t Three tab stops" << endl
//2 ways to display the Price label.
<< "Price:\t\t" << "10.00" << "\t\t Two tabs" << endl
<< "Price:....\t" << "10.00" << "\t\t Spaces before one tab" << endl
<< "Quantity: \t" << "50" << endl
<< endl << endl
<< "Thank you!\n\n";
return;
}
//end of main
Sample Output:
P03b - Juan Marquez TR 1:00pm
1 2 3 4 5 6 7 8
12345678901234567890123456789012345678901234567890123456789012345678901234567890
1234567890
x x x Three tab stops
Price: 10.00 Two tabs
Price:.... 10.00 Spaces before one tab
Quantity: 50
Thank you!
Press any key to continue