Starting from:

$25

CSCI251-Lab Task 3 Formatted I/O and Unformatted I/O Solved

Question 1 (Formatted I/O)
 

You are responsible to maintain a simple sales record for the sales of a company.  The company keeps a text file to store the records of the monthly sales made by the salespersons that contains the employee number, name, and sales made for each salesperson. The file may be formatted in the following way:

 

 

12345  
Ali Baba
 
1040.00
12233  
Sinbad  
 
35.98
23781  
Spongebob
 
199.00
67543  
Cinderella
 
500.50
23781  
Spongebob
 
1000.00
12345  
Ali Baba
 
80.00
67543  
Cinderella
 
67.50
 

Your task is to write a program that will allow new sales records to be written to the file and also to read the file  and print out the total sales made by each salesperson together with the overall total sales made so far. Filenames should be entered by the user.

 

Declare suitable data structure to keep each record. Use individual functions to perform the calculations and display. Include necessary error checking in your program and provide a well-formatted output.

 

 

Question 2 (Formatted I/O and Unformatted I/O)
 

You are provided with a text file (chemicalElements.txt) containing a list of chemical elements. Each line on the text file will contain the atomic mass, followed by the element name, chemical symbol, and an integer atomic number. Example of a few lines from the file is as follows:

 

  

1.0079 Hydrogen 

1
4.0026 Helium  
He 
2
6.941 Lithium  
Li 
3
 

Your task is to read the information for each of the element in this file and produce a binary file containing records of these chemical elements. Each record should be stored in a struct variable declared as: struct ChemicalElement 



  int atomicNumber;   char name[100];   char symbol[3]; 

     float mass; 

}; 

 

Once the binary file has been created, allow the user to perform a search on the binary file by providing the element name or symbol (display all the details if found), display all the chemical elements’ details that have atomic mass greater than a given value, display the details of all the chemical elements with the atomic number in between two given values, or display the details of a chemical element by giving the record number. The details of the chemical element will then be displayed on standard output.

 

Separate function should be written to:

1.     Read records from the text file and write to binary file.

2.     Search by name or symbol

3.     Display data with atomic mass greater than the value passed to it

4.     Display data between two given atomic number

5.     Display data given a record number

All functions should be called from main().

 

 

More products