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

  Write a program that will be used to gather statistical data

Write a program that will be used to gather statistical data about the number of movies

  Design a nested program

How many levels of nesting are there in this design?

  Write program which prompts user to enter numbers

Write down the program which prompts the user to enter numbers, findsout how many positive and negative values have been entered, and calculates sum and average of numbers entered.

  Write a pseudocode statement

Assume that a program has two string variables named str1 and str2. Write a pseudocode statement that assigns an all uppercase version of str1 to the str2 variable. is str.add(str1,str2) part of it?

  Design and implement a library system

Design and implement a library system that does the following: ? Takes details of a student/library users: first name, last name, other names, user ID number, and nationality.

  Write the output of the program

Design a C++ program that will interactively prompt for and read the name of the input file interactively prompt for and read the name of a file to write the output of the program to write the following to the specified output file your name, sect..

  Make 2-dimensional array

make 2-dimensional array a bit of life and bringing them from the abstract to the concrete realms

  Searching f and removing certain states from the hash table

use the class hashT, ''Hashing: Implementation Using Quadratic Probing,'' which uses quadratic probing to resolve collision, to create a hash table to keep track of each state's information. Use the state's name as the key to determine the hash addre..

  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.

  The mean and standard deviation

How do i write a program in c++ that use functions max, min, the total numbers, the mean and standard deviation to read a file text and return these values from the file text. note the file text has random numbers. note im not suppose to use arrays.

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Function declare that it can throw an ioexception

Every C++ function that performs file I/O will thus need to either declare that it can throw an IOException, or contain a try-catch-finally block to deal with it. Response?

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