help why does my output table's came out that way even after i added the get line?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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
Transcribed Image Text: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
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education