In: Computer Science
Using Dev-C++ write a program that allows a small business owner
to input, in parallel arrays, the type of item, its cost, and the
number in stock. The program should output this information in the
form of a table. The output will look something like below. Also,
assume for a finite number of item name of 3
Item Name Cost Number in Stock
Widget 25.00 4
... ... ...
Wombet 47.50 9
Prelude to Programming (6th edition)
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.
If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.
Thank You!
===========================================================================
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main(){
string names[3];
double prices[3];
int quantities[3];
for(int i=0; i<3; i++){
cout<<"Enter Details for Item
#" << i+1<<endl;
cout<<"Enter item name: ";
getline(cin,names[i],'\n');
cout<<"Enter item price: ";
cin >> prices[i];
cout<<"Enter quantity: "; cin
>> quantities[i];
cin.ignore(256,'\n');
cout<<endl;
}
cout<<left<<setw(15)<<"Item
Name";
cout<<right<<setw(10)<<"Cost";
cout<<right<<setw(20)<<"Number in
Stock";
cout<<endl;
for(int i=0; i<3; i++){
cout<<left<<setw(15)<<names[i];
cout<<right<<setprecision(2)<<fixed<<showpoint<<setw(10)<<prices[i];
cout<<right<<setw(10)<<quantities[i];
cout<<endl;
}
return 0;
}
================================================================