المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : مساله سي ++ ضروري جدا جدا


eshrag.net
08-01-2010, 12:11 PM
اريد مساعدة لحل مسالة c++

ضروري جدا اريدها بالثلاثاء

بليييز

هذا هو السؤال

A company records its sales for the day in a file called sales.txt.
Each line in the file contains the following information:
ID number of the item (3-digit integer) and the quantity sold for that item. The two pieces of information are separated by space.
Table.1 gives a full description of the items that the company sales.
ID number
Sales price (OR)
Item designation
100
25.5
Web Camera
200
5.2
mouse
300
35
Hard Disk
400
9.75
Keyboard


Table.1: Description of the Items sold by the company


Problem Definition
Write a C++ program that reads the file sales.txt and displays for each item that the company sales, its ID, its designation, the number of units sold and the total amount of sales for that item.
The program should also display the number of invalid inputs (i.e. when ID is unknown) and the total amount of sales.

Figure.1.b shows a sample run produced by the program when sales.txt contains data shown in Figure.1.a

Note:

All real numbers should be displayed with 2 decimals.
If the input file does not exist you should display an adequate error message and stop
200 5
100 3
500 7
200 3
100 3
600 10
400 5






Figure1.a. Sample of sales.txt


Figure.1b: Sample run of the program for data stored in sales.txt shown in Figure1.a