In: Computer Science
Coding in C++: For this verse, you need to write a program that asks the user to input the inventory id number (integer) and the price (float) for 5 inventory items. Once the 5 inventory items are input from the user, output the results to the screen. Please ensure you use meaningful names for your variables. If your variables are not named meaningfully, points will be deducted.
Source code:
#include<iostream>
using namespace std;
int main()
{
int inventory_id[5],i=0;
float inventory_price[5];
printf("Enter the inventory id and price\n");
for(i=0;i<5;i++)
{
cin>>inventory_id[i]>>inventory_price[i];
}
printf("the inventory id and price are \n");
for(i=0;i<5;i++)
{
cout<<inventory_id[i]<<"
"<<inventory_price[i];
cout<<"\n";
}
return 0;
}
Output:
Enter the inventory id and price
1 2.5
2 2.6
3 3.6
4 5.6
5 6.3
the inventory id and price are
1 2.5
2 2.6
3 3.6
4 5.6
5 6.3
--------------------------------
Process exited after 17.56 seconds with return value 0
Press any key to continue . . .