Calculate the price per item for that purchase

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

Computer Science Program-

Write a C++ program that will simulate a store where the purchase information will be read in from an input file. The program will calculate the price per item and the total cost of the entire purchase. The output will use formatted output tools to provide spacing and the exact number of decimal places to be displayed.

Declare a struct type that will represent a single purchase. The required fields are:
Item name - string
Quantity of items (how many are being purchased) - int
Cost (what does it cost to buy that many items) - double
Price per item (a calculated value based on quantity and cost) - double

The program should

Ask the user for the name of the input file and open that file for reading
While there is more purchase information in the file

read the information for one purchase into a variable of your struct type.
calculate the price per item for that purchase
output the data in formatted columns (as in program #1)
add the item cost into a total cost variable

After all file data has been processed, write out the total cost line

For an input file containing
Pencils
3
12.4
BlueBooks 13
3.99
the output would look something like this

Qty

Item

Price/Item

Cost

3

Pencils

4.13

12.40

13

BlueBooks

0.31

3.99

 

 

Total Cost

16.39

Use functions to do all of the major tasks (input, calculation, output)

Required Comments: Name block

Descriptive comment at the beginning of the whole program Descriptive comment at the beginning of each function

Reference no: EM131230380

Questions Cloud

Create a new product that would appeal to your market : Develop at least one question for each characteristic of the target market (demographic, geographic, psychographic, and behavioral) that will be important for you as you determine the marketing strategy for this new product.
List several of the technical requirements placed : List several of the technical requirements placed on software applications (§ 1194.21) and web-based applications (§ 1194.22), then explain the purpose each serves.
What is the net present value at discount rate : FIN-351 Fall 2016 Assignment. The Hudson Corporation makes an investment of $24,000 that provides the following cash flow: What is the net present value at an 8 percent discount rate
Shows how the it and biblical concepts are related : Create a document which shows how the IT and Biblical concepts are related. (What are the similarities between these ideas?)
Calculate the price per item for that purchase : Read the information for one purchase into a variable of your struct type. Calculate the price per item for that purchase. Output the data in formatted columns (as in program #1). Add the item cost into a total cost variable.
It has been said there is no bad data, just bad management : To what extent should end users be involved in the selection of a database management system and database design?
Check the given essay and rewrite it : Check the given essay. and rewrite it if needed. - The essay topic is : "Bullying". -  One of the biggest problems that seen these days is bullying.
What are the consequences of an organization : What are the consequences of an organization not having an information policy?
Describe an effective e-mail and web use policy : Should managers inform employees that their Web behavior is being monitored? Or should managers monitor secretly? Why or why not?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Why encapsulation and inheritance make programming difficult

Why do C++ capabilities such as polymorphism, encapsulation, and inheritance make programming difficult

  Given two bit strings of length n,find the bitwise and,xor

Use a computational program (C++) you have written to do the following exercises.Given two bit strings of length n (n equal or bigger 16), find the bitwise AND, bitwise XOR of these strings.

  Compute and display net weekly pay

You need to prepare a C++ program in which you declare variables that holds an hourly wage, a number of hours worked, and a withholding percentage.

  Cryptanalysis of substitution ciphers

Cryptanalysis project consists of a software implementation of an algorithm that tries to decrypt an L-symbol challenge ciphertext using a plaintext dictionar - implementation has to be in C or C++ as these are the most recommended (for combined p..

  What tasks are involved in designing database table

WHAT IS THE NAME FOR COLUMN THAT UNIQUELY IDENTIFIES A RECORD?

  The definition for a printallplayers() function

Add the Prototype, a call and the definition for a printAllPlayers() function that prints to STDOUT (using cout) each players name and all of their at-bat stats. Only print out the values of the stats array up to timesAtBat.

  Briefly review programming concepts and discrete mathematics

Discuss the aims and goals of this text and briefly review programming concepts and discrete mathematics -

  Reverses the characters in a character array

Write the function reverseit that reverses the characters in a character array. You must also write main that calls reverseit.

  The purpose of the program is to prepare an accounting

the purpose of the program is to prepare an accounting database for e.g. a dorms kitchen to keep track of the

  Write an interactive c program to process the exam scores

Write an interactive C program to process the exam scores for a group of students in a C programming course. Begin by specifying the number of exam scores for each student.

  Compute the power loss in a transmission line

Write a program to compute the power loss in a transmission line with a resistance of 0.05 ohms/mile. Compute the power loss if 500 kw of power is transmitted from a power generating station to cities at distances of 20, 30, 40, 50,....., 100 mile..

  Design an instruction that useful for handling while loops

The loop instructions discussed in the text were for handling for loops. Design an instruction that might be useful for handling common while loops instead.

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