Displays columns titled "name", "quantity", "price", value

Assignment Help C/C++ Programming
Reference no: EM13161437

Write a program that displays columns titled "Name", "Quantity", "Price", and "Value". The fourth column contains the result of multiplying each item's quantity by its price. In addition, the program should calculate and display the total value of the items in inventory. Display the price, value, and total value with two decimal places. Save and the run the program

I began with the following cpp, but I am experiencing difficulty in getting my columns to align.

Here is the cpp:

#include <iostream>
using namespace std;

int main(){
   string caName[5] = {};
   int iaQuantity[5] = {};
   double iaPrice[5] = {};
   double iaValue[5] = {};
  
   for (int x = 0; x<5; ++x)
   {
   cout << "Enter an item: ";
   cin >> caName[x];
}
cout << endl;
   for (int x = 0; x<5; ++x)
   {
   cout << "Enter " << caName[x] << "'s quantity: ";
   cin >> iaQuantity[x];
}
cout << endl;
   for (int x = 0; x<5; ++x)
   {
   cout << "Enter " << caName[x] << "'s price: ";
   cin >> iaPrice[x];
}
cout << endl;
   for (int x = 0; x<5; ++x)
   {
   iaValue[x] = iaQuantity[x]*iaPrice[x];
}


cout<< endl;
cout << "Name""\t""\t""Quantity""\t""Price""\t""\t""Value" << endl;
cout << endl;
   for (int x = 0,a = 0, p = 0; x<4, a < 5, p < 5; ++x, ++a, ++p)
   {cout << caName[x] <<"\t"""#";
   cout << iaQuantity[a] <<"\t""\t""$";
   cout << iaPrice[a] <<"\t""\t""$";
   cout << iaValue[a] <<"\t""\t"" ";
   cout << "\n";
}
   }

I must enter the following information to execute the program:

Watch #400 $55.54
Ring #550 $99.99
Bracelet #600 $20
Earrings #100 $10.99
Pins #10 $24.35

 

 

Reference no: EM13161437

Questions Cloud

U.s. labor markets if immigration is not controlled : Immigration is a major topic of concern in today's economy. What are the possible problems and solutions for these concerns? What could happen to the U.S. labor markets if immigration is not controlled?
State equilibrium mixture of gases at a certain temperature : Ethylene, C2H4, and water react under appropriate conditions to give ethanol. The reaction is C2H4(g) + H2O(g) C2H5OH(g) An equilibrium mixture of these gases at a certain temperature
Const int num_years : How do you get this program to get both player input and then display results(As described on bottom) #include  const int NUM_YEARS=15;//The number of years const int NAME_SIZE=32;//The max size of the player name string
Which process produces the least quantity of atp : Which process produces the least quantity of ATP per molecule of glucose oxidized?
Displays columns titled "name", "quantity", "price", value : Write a program that displays columns titled "Name", "Quantity", "Price", and "Value". The fourth column contains the result of multiplying each item's quantity by its price. In addition, the program should calculate and display the total value of th..
State what is the partial pressure of h : Suppose it was found that in an equilibrium mixture of these gases the partial pressure of NH3(g) is 24.9 atm and the partial pressure of N2 is 6.68 atm. What is the partial pressure of H2(g)?
Which of the following is true of innate behavior : which of the following is true of innate behavior.
What are its possible advantages and drawbacks : What is the assignment rule and what are its possible advantages and drawbacks?
Draw a 16 input sorter : Let "10 10 11 10 00 11 10 00" be your input. Draw a 16 input sorter that uses the divide-and-conquer idea of MergeSort. Show the values on each wire at intermediate steps (i.e. output after a half cleaner of 16 inputs).

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Why does the neverwet spray protect it from water

As is know, acetone is a polar molecule like water, so isn't it suppose to mix? So my question is: why does the Neverwet spray protect it from water but not from oils and detergents?

  Program to check compatibity for matrix multiplication

Write down program in C++ for matrix multiplication. Program must accept dimension of both matrices to be multiplied and check for compatibity.

  Include the iostream, fstream, string, and cctype libraries

1. Include the iostream, fstream, string, and cctype libraries in your program.

  Write test program to call function several times for gcd

Greatest common divisor of two integers is largest integer which will evenly divide both integers. Implement this function in assembly language and write test program which calls function several times, passing it different values.

  Write a c function to convert gallons-quarts-pints and cups

Write a C function named liquid() that is to accept an integer number and the addresses of the variables gallons, quarts, pints, and cups.

  Three or more dimensions

What kind of program, or problem, might necessitate arrays of three or more dimensions?

  Skills required by personnel working in information security

What skills are required by personnel working in information security? Write down some job titles in the field and come up with some required qualifications and some desirable qualifications.

  Consists of an employee''s last name

Each input line consists of an employee's last name, first name, current base salary, total sales and percent commission. For example, in the first input line, the last name of the employee is Thomas, the first name is Andrew, the current base salary..

  Asks the user for the name of an input file and translates

Write a C++ program that asks the user for the name of an input file and translates the contents of that input file using ROT13. Your  main  function should be responsible for reading the input file and coordinating calls to a value-returning functio..

  Ruby implement primitive types

How does Ruby implement primitive types, such as those for integer and floating-point data?  3-What is the single most important practical difference between Smalltalk and C++?

  Create a graphical (not text-based) visual c++ program

Create a graphical (not text-based) Visual C++ program that allows the user to enter the coefficients for a system of four equations with four unknowns. Include a button that when clicked, will solve the system of equations and display the results in..

  Wrtie a function called gen_rand_double_array

Wrtie a function called gen_rand_double_array that generates 900 samples of size 22500 random numbers from U(10, 12). For each of these 900 samples, write a main funciton that calculates the mean and finds the simulated probability that the mean is b..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd