The input file salesin. txt contains a series of lines with three numbers on each line. Each line corresponds to a certain item which has been bought and then subsequently sold. The first number is the buying price of the item, the second number is the selling price of the item, and the third number is the quantity sold (integer). We are interested in keeping track of the total profit and total loss over all of the items listed in the file. For example, if a line in the $2.12 and this file contains 1.34 1.87 4, then that item yielded a profit of 4(1.87 - 1.34) number should be added to the total profit. Similarly, if another line reads 3.22 2.87 6, then that item had a loss of 6(3.22 - 2.87) = $2.10 and this number should be added to the total loss. Write a program which repeatedly reads the buying, selling, and quantity values from salesin.txt and reports the information to an output file salesout.txt along with the item profit and total running profit, or the item loss and total running loss. For example, if salesin. txt contains the following lines: 2.56 3.44 8 1.24 1.69 5 8.44 7.32 3 3.67 4.12 8. 4.33 4.01 5 then salesout.txt should contain 2.56 3.44 8: profit = 7.04, total profit 7.04 1.24 1.69 5: profit 2.25 total profit = 9.29 8.44 7.32 3: loss 3.36, total loss = 3.36 3.67 4.12 8: profit 3.60 total profit - 12.89 1.60 4.33 4.01 5: loss 1 total loss 4.96 man -

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Using c++ programming, plz complete the coding shown below.
#include<stdio.h>
int main(void) {
while (fscanf(fin, "%f %f %d",&v1, &v2, &v3) !=EOF) {
return 0;
Transcribed Image Text:#include<stdio.h> int main(void) { while (fscanf(fin, "%f %f %d",&v1, &v2, &v3) !=EOF) { return 0;
The input file salesin. txt contains a series of lines with three numbers on each line. Each
line corresponds to a certain item which has been bought and then subsequently sold. The
first number is the buying price of the item, the second number is the selling price of the item,
and the third number is the quantity sold (integer). We are interested in keeping track of the
total profit and total loss over all of the items listed in the file. For example, if a line in the
file contains 1.34 1.87 4, then that item yielded a profit of 4(1.87 1.34) = $2.12 and this
number should be added to the total profit. Similarly, if another line reads 3.22 2.87 6, then
that item had a loss of 6(3.22 - 2.87) $2.10 and this number should be added to the total
loss.
Write a program which repeatedly reads the buying, selling, and quantity values from salesin.txt
and reports the information to an output file salesout.txt along with the item profit and
total running profit, or the item loss and total running loss.
For example, if salesin.txt contains the following lines:
2.56 3.44 8
1.24 1.69 5
8.44 7.32 3
3.67 4.12 8
4.33 4.01 5
-
then salesout.txt should contain
profit = 7.04
profit = 9.29
2.56 3.44 8: profit = 7.04, total
1.24 1.69.5: profit = 2.25, total
loss
3.36, total loss = 3.36
profit = 3.60 total profit = 12.89
1.60, total loss
8.44 7.32 3:
3.67 4.12 8:
4.33 4.01 5: loss
4.96
Transcribed Image Text:The input file salesin. txt contains a series of lines with three numbers on each line. Each line corresponds to a certain item which has been bought and then subsequently sold. The first number is the buying price of the item, the second number is the selling price of the item, and the third number is the quantity sold (integer). We are interested in keeping track of the total profit and total loss over all of the items listed in the file. For example, if a line in the file contains 1.34 1.87 4, then that item yielded a profit of 4(1.87 1.34) = $2.12 and this number should be added to the total profit. Similarly, if another line reads 3.22 2.87 6, then that item had a loss of 6(3.22 - 2.87) $2.10 and this number should be added to the total loss. Write a program which repeatedly reads the buying, selling, and quantity values from salesin.txt and reports the information to an output file salesout.txt along with the item profit and total running profit, or the item loss and total running loss. For example, if salesin.txt contains the following lines: 2.56 3.44 8 1.24 1.69 5 8.44 7.32 3 3.67 4.12 8 4.33 4.01 5 - then salesout.txt should contain profit = 7.04 profit = 9.29 2.56 3.44 8: profit = 7.04, total 1.24 1.69.5: profit = 2.25, total loss 3.36, total loss = 3.36 profit = 3.60 total profit = 12.89 1.60, total loss 8.44 7.32 3: 3.67 4.12 8: 4.33 4.01 5: loss 4.96
Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education