I am trying to create a table for this program, I could figured almost everythin
ID: 3646458 • Letter: I
Question
I am trying to create a table for this program, I could figured almost everything out. I just have one program, How do I get the the ------ and the total match perfectly with the Amount ColumnPrice
Price Units Amount
9.92 1 123
6.32 2 123
12.63 3 123
5.95 4 123
10.29 5 123
-------- <---- Match perfectly
Total: 12345 <-----Match perfectly with the column
Thanks!
#include<iostream>
using namespace std;
int main()
{
double total=0;
double prices[]={9.92, 6.32, 12.63, 5.95,10.29};
int i;
double units[5],amounts[5];
cout<<"Please, enter the number of units "<<endl;
for(i=0;i<5;i++)
cin>>units[i];
for(i=0;i<5;i++) //computing the product values
amounts[i]=prices[i]*units[i];
cout<<"Price Units Amount "<<endl;
for(i=0;i<5;i++)
cout<<" "<<prices[i]<<" "<<" "<<units[i]<<" "<<" "<<amounts[i]<<endl;
for(i=0;i<5;i++)
total=total+amounts[i];
cout<<" "<<"------";
cout<<" total amount: "<<" "<<total;
system("pause>nul");
return 0;
}
Explanation / Answer
#include using namespace std; int main() { double total=0; double prices[]={9.92, 6.32, 12.63, 5.95,10.29}; int i; double units[5],amounts[5]; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.