help why does my output table's came out that way even after i added the get line?
Please help why does my output table's came out that way even after i added the get line?
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
// structure
struct Hat
{
string brand;
string color;
float price;
};// declare the structure variable
int main()
{
// declare an array of Hats of size 5
Hat hat[5];
int i;
cout<<"Welcome to Hats For U!\n";
/* loop to read values for 5 hats */
for(i=0;i<5;i++){
cout<<"Hat "<<(i+1)<<"\n";
cout<<"Enter the brand of hat: ";
cin>>hat[i].brand;
getline(cin,hat[i].brand);
cout<<"Enter the hat color: ";
cin>>hat[i].color;
cout<<"Enter the hat price(RM): ";
cin>>hat[i].price;
}
// display messages
cout<<"\n\nRECORD OF HATS \n";
cout<<"----------------------------------------------------------\n";
cout<<setw(35)<<left<<"Brand"<<setw(10)<<left<<"Color"<<setw(5)<<left<<"Price(RM)\n";
cout<<"----------------------------------------------------------\n";
/* loop to display values for 5 hats */
for(i=0;i<5;i++){
cout<<setw(35)<<left<<hat[i].brand;
cout<<setw(10)<<left<<hat[i].color;
cout<<setw(5)<<left<<hat[i].price<<endl;
}
return 0;
}
![Welcome to Hats For U!
Hat 1
Enter the brand of hat: ADIDAS
Enter the hat color: BLACK
Enter the hat price(RM): 99
Hat 2
Enter the brand of hat: LOUIS VUITTON
Enter the hat color: BROWN
Enter the hat price(RM): 289
Hat 3
Enter the brand of hat: NIKE
Enter the hat color: WHITE
Enter the hat price(RM): 122
Hat 4
Enter the brand of hat: REEBOK
Enter the hat color: YELLOW
Enter the hat price(RM): 79
Hat 5
Enter the brand of hat: DIOR
Enter the hat color: WHITE
Enter the hat price(RM): 178
RECORD OF HATS
Brand
Color
Price(RM)
BLACK
99
VUITTON
BROWN
289
WHITE
122
YELLOW
79
WHITE
178
Process exited after 94.36 seconds with return value e
Press any key to continue](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa5885545-f3ae-4130-b6e2-b82385174675%2F1864b36c-fcdd-40d3-a263-3c6b62dca959%2Fndg7hllu_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)