1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#include <iostream>
#include <iomanip>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using namespace std;
using std::setw;
using std::setprecision;
using std::ios;
int main()
{
string Joe, Hana, Smith, Troy;
float income1 = 57000.383, income2 = 60000.432, income3 = 45000.123, income4 = 65000.543;
double gpa1 = 3.334, gpa2 = 3.892, gpa3 = 2.744, gpa4 = 4.154;
int age = 34, age2 = 23, age3 = 37, age4 = 43;
cout <<setw(13) << "Names: " << setw(9) << "Joe" << setw(15) << "Hana" << setw(15) << "Smith" << setw(15) << "Troy" < endl;
cout << "Income in $: " << setw(13) << income1 << setw(14) << income2 << setw(14) << income3 << setw(16) << income4 << endl;
cout.setf(ios::fixed);
cout << setprecision(2) <<setw(13) << "GPA:" << setprecision(3) << setw(11) << gpa1 << setw(14) << gpa2 << setw(14) << gpa3 << setw(16) << gpa4 <<"\n\n" << endl;
cout << setw(13) << "Names: " << setw(9) << "Joe" << setw(15) << "Hana" << setw(15) << "Smith" << setw(15) << "Troy" << endl;
cout.setf(ios::fixed);
cout << setprecision(2) << "Income in $: " << setw(14) << income1 << setw(14) << income2 << setw(14) << income3 << setw(16) << income4 << endl;
cout <<setw(13) << " Age: " << setw(8) << age1 << setw(14) << age2 << setw(14) << age3 << setw(16) << age4 << endl;
return 0;
}
/*
#include <iostream>
#include <iomanip>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using namespace std;
using std::setw;
using std::setprecision;
using std::ios;
int main()
{
string Joe, Hana, Smith, Troy;
float income1 = 57000.383, income2 = 60000.432, income3 = 45000.123, income4 = 65000.543;
double gpa1 = 3.334, gpa2 = 3.892, gpa3 = 2.744, gpa4 = 4.154;
int age1 = 34, age2 = 23, age3 = 37, age4 = 43;
cout <<setw(13) << "Names: " << setw(9) << "Joe" << setw(15) << "Hana" << setw(15) << "Smith" << setw(15) << "Troy" << endl;
cout << "Income in $: " << setw(13) << income1 << setw(14) << income2 << setw(14) << income3 << setw(16) << income4 << endl;
cout.setf(ios::fixed);
cout << setprecision(2) <<setw(13) << "GPA:" << setprecision(3) << setw(11) << gpa1 << setw(14) << gpa2 << setw(14) << gpa3 << setw(16) << gpa4 <<"\n\n" << endl;
cout << setw(13) << "Names: " << setw(9) << "Joe" << setw(15) << "Hana" << setw(15) << "Smith" << setw(15) << "Troy" << endl;
cout.setf(ios::fixed);
cout << setprecision(2) << "Income in $: " << setw(14) << income1 << setw(14) << income2 << setw(14) << income3 << setw(16) << income4 << endl;
cout <<setw(13) << " Age: " << setw(8) << age1 << setw(14) << age2 << setw(14) << age3 << setw(16) << age4 << endl;
return 0;
}
*/
|