#include #include #include using namespace std; // structure struct Hat { string brand; string color; float price; }; // Customer structure struct Customer { string fullName ; int age ; Hat hat; // Hat structure (nested in Customer) }; int main() { // declare 5 variables of Customer Customer customer_1,customer_2,customer_3,customer_4,customer_5; cout<<"Welcome to Hats For U!\n"; cout<<"Customer 1\n"; cout<<"Enter customer's Full Name: "; getline(cin,customer_1.fullName); cout<<"Enter customer's age: "; cin>>customer_1.age; cout<<"Enter the brand of hat: "; cin>>customer_1.hat.brand; cout<<"Enter the hat color: "; cin>>customer_1.hat.color; cout<<"Enter the hat price(RM): "; cin>>customer_1.hat.price; cout<<"Hat 2\n"; cout<<"Enter customer's Full Name: "; getline(cin,customer_2.fullName); getline(cin,customer_2.fullName); cout<<"Enter customer's age: "; cin>>customer_2.age; cout<<"Enter the brand of hat: "; cin>>customer_2.hat.brand; cout<<"Enter the hat color: "; cin>>customer_2.hat.color; cout<<"Enter the hat price(RM): "; cin>>customer_2.hat.price; cout<<"Hat 3\n"; cout<<"Enter customer's Full Name: "; getline(cin,customer_3.fullName); getline(cin,customer_3.fullName); cout<<"Enter customer's age: "; cin>>customer_3.age; cout<<"Enter the brand of hat: "; cin>>customer_3.hat.brand; cout<<"Enter the hat color: "; cin>>customer_3.hat.color; cout<<"Enter the hat price(RM): "; cin>>customer_3.hat.price; cout<<"Hat 4\n"; cout<<"Enter customer's Full Name: "; getline(cin,customer_4.fullName); getline(cin,customer_4.fullName); cout<<"Enter customer's age: "; cin>>customer_4.age; cout<<"Enter the brand of hat: "; cin>>customer_4.hat.brand; cout<<"Enter the hat color: "; cin>>customer_4.hat.color; cout<<"Enter the hat price(RM): "; cin>>customer_4.hat.price; cout<<"Hat 5\n"; cout<<"Enter customer's Full Name: "; getline(cin,customer_5.fullName); getline(cin,customer_5.fullName); cout<<"Enter customer's age: "; cin>>customer_5.age; cout<<"Enter the brand of hat: "; cin>>customer_5.hat.brand; cout<<"Enter the hat color: "; cin>>customer_5.hat.color; cout<<"Enter the hat price(RM): "; cin>>customer_5.hat.price; cout<<"\n\nRECORD OF HATS \n"; cout<<"------------------------------------------------------------------------------\n"; cout<
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
// structure
struct Hat
{
string brand;
string color;
float price;
};
// Customer structure
struct Customer
{
string fullName ;
int age ;
Hat hat; // Hat structure (nested in Customer)
};
int main()
{
// declare 5 variables of Customer
Customer customer_1,customer_2,customer_3,customer_4,customer_5;
cout<<"Welcome to Hats For U!\n";
cout<<"Customer 1\n";
cout<<"Enter customer's Full Name: ";
getline(cin,customer_1.fullName);
cout<<"Enter customer's age: ";
cin>>customer_1.age;
cout<<"Enter the brand of hat: ";
cin>>customer_1.hat.brand;
cout<<"Enter the hat color: ";
cin>>customer_1.hat.color;
cout<<"Enter the hat price(RM): ";
cin>>customer_1.hat.price;
cout<<"Hat 2\n";
cout<<"Enter customer's Full Name: ";
getline(cin,customer_2.fullName);
getline(cin,customer_2.fullName);
cout<<"Enter customer's age: ";
cin>>customer_2.age;
cout<<"Enter the brand of hat: ";
cin>>customer_2.hat.brand;
cout<<"Enter the hat color: ";
cin>>customer_2.hat.color;
cout<<"Enter the hat price(RM): ";
cin>>customer_2.hat.price;
cout<<"Hat 3\n";
cout<<"Enter customer's Full Name: ";
getline(cin,customer_3.fullName);
getline(cin,customer_3.fullName);
cout<<"Enter customer's age: ";
cin>>customer_3.age;
cout<<"Enter the brand of hat: ";
cin>>customer_3.hat.brand;
cout<<"Enter the hat color: ";
cin>>customer_3.hat.color;
cout<<"Enter the hat price(RM): ";
cin>>customer_3.hat.price;
cout<<"Hat 4\n";
cout<<"Enter customer's Full Name: ";
getline(cin,customer_4.fullName);
getline(cin,customer_4.fullName);
cout<<"Enter customer's age: ";
cin>>customer_4.age;
cout<<"Enter the brand of hat: ";
cin>>customer_4.hat.brand;
cout<<"Enter the hat color: ";
cin>>customer_4.hat.color;
cout<<"Enter the hat price(RM): ";
cin>>customer_4.hat.price;
cout<<"Hat 5\n";
cout<<"Enter customer's Full Name: ";
getline(cin,customer_5.fullName);
getline(cin,customer_5.fullName);
cout<<"Enter customer's age: ";
cin>>customer_5.age;
cout<<"Enter the brand of hat: ";
cin>>customer_5.hat.brand;
cout<<"Enter the hat color: ";
cin>>customer_5.hat.color;
cout<<"Enter the hat price(RM): ";
cin>>customer_5.hat.price;
cout<<"\n\nRECORD OF HATS \n";
cout<<"------------------------------------------------------------------------------\n";
cout<<setw(20)<<left<<"Full Name"<<setw(20)<<left<<"Age"<<setw(20)<<left<<"Brand"<<setw(20)<<left<<"Color"<<setw(20)<<left<<"Price(RM)\n";
cout<<"------------------------------------------------------------------------------\n";
cout<<setw(20)<<left<<customer_1.fullName;
cout<<setw(20)<<left<<customer_1.age;
cout<<setw(20)<<left<<customer_1.hat.brand;
cout<<setw(20)<<left<<customer_1.hat.color;
cout<<setw(20)<<left<<customer_1.hat.price;
cout<<setw(20)<<left<<customer_2.fullName;
cout<<setw(20)<<left<<customer_2.age;
cout<<setw(20)<<left<<customer_2.hat.brand;
cout<<setw(20)<<left<<customer_2.hat.color;
cout<<setw(20)<<left<<customer_2.hat.price;
cout<<setw(20)<<left<<customer_3.fullName;
cout<<setw(20)<<left<<customer_3.age;
cout<<setw(20)<<left<<customer_3.hat.brand;
cout<<setw(20)<<left<<customer_3.hat.color;
cout<<setw(20)<<left<<customer_3.hat.price;
cout<<setw(20)<<left<<customer_4.fullName;
cout<<setw(20)<<left<<customer_4.age;
cout<<setw(20)<<left<<customer_4.hat.brand;
cout<<setw(20)<<left<<customer_4.hat.color;
cout<<setw(20)<<left<<customer_4.hat.price;
cout<<setw(20)<<left<<customer_5.fullName;
cout<<setw(20)<<left<<customer_5.age;
cout<<setw(20)<<left<<customer_5.hat.brand;
cout<<setw(20)<<left<<customer_5.hat.color;
cout<<setw(20)<<left<<customer_5.hat.price;
return 0;
}
Above is my code, can you please help me fix the table so that it is even and aligned with each other?
Step by step
Solved in 3 steps with 2 images