Question

Write a C program that takes inventory data from a file and loads a structure of up to 100 items

defined as:

struct item

{

int item_number;

char item_name[20];

char item_desc[30];

float item_price;

}

I called mine: struct item inventory[100]; (you may use any name you wish)

I will let you decide the appropriate prompts and edit messages. You will read the data

from the data file and store the info in an array. Assume no more than 100 records will

be in the data file. You may use the data below for testing purposes with the attached

file.

Once the program opens the file, and reads the data into the array, the program should

then give the user the option to SORT THE DATA IN ASCENDING ORDER BY ITEM

NUMBER, OR ITEM NAME OR ITEM DESC, OR ITEM PRICE, and output the

inventory data in report form of your design with alignment, or exactly as follows below.

The report will also be directed to an output text file (named report7.txt) with the same

output as printed to the screen.

Hints/requirements:

• Program without sort options is a 10 point deduction.

• Program with no output to invreport.txt is a 10 point deduction

• Without current date and time stamp is a 5 point deduction

• No data validation is required (assume it was validated before writing to the file)

• To Simplify your work I did not use any ‘white-space’ in the descriptions

• You must open the file in r mode such as: in_file_ptr = fopen(file_name, "r")

• I read the file: fscanf(in_file_ptr, "%i", &inventory[x].item_number); /* etc. */

The sample data file contains data similar to the following (in a text file)

Welcome to Inventory Center Enter File Name: n5.txt There are 5 items in inventory. Sort by: Item Number (1), Item Name (N),

0 0
Add a comment Improve this question Transcribed image text
Answer #1

tem temp nd total R ead 0, ile na m,

printf Cunable やopen CPI ein), total Read ะ Staten(buff ea); case n

case baeak) casefnvt[j)- teme br eak) case tp case ptf ern _ name ?rvtlH.ttem r disc, învt C39.1tem-foo t ces. , item.pstee tern-ri Umbes,

Add a comment
Know the answer?
Add Answer to:
Write a C program that takes inventory data from a file and loads a structure of up to 100 items ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please write in C++ Write a program that uses a structure to store the following inventory...

    please write in C++ Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or the keyboard Item name (string) Quantity on hand(int) Wholesale cost(double) Retail Cost(double) The program should have a menu that allows the user to perform the following tasks: Add new records to the file Display any record in the file User will provide the name of the item or the...

  • Write a program that will take input from a file of numbers of type double and...

    Write a program that will take input from a file of numbers of type double and output the average of the numbers in the file to the screen. Output the file name and average. Allow the user to process multiple files in one run. Part A use an array to hold the values read from the file modify your average function so that it receives an array as input parameter, averages values in an array and returns the average Part...

  • Inventory Program (C++) Write a program that uses a structure to store the following inventory data...

    Inventory Program (C++) Write a program that uses a structure to store the following inventory data in a file: - Item Description -Quantity on Hand -Wholesale cost -Retail cost -Date Added to Inventory The program should have a menu that allows the user to perform the following tasks: -Add new records to file -Display any record in the file -Change any record in the file Input Validation: The program should not accept quantities, or wholesale or retail costs, less than...

  • The name of the C++ file must be search.cpp Write a program that will read data...

    The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...

  • Using c 3 File Input & Data Processing Reading data from a file is often done in order to pro...

    using c 3 File Input & Data Processing Reading data from a file is often done in order to process and aggregate it to get ad- ditional results. In this activity you will read in data from a file containing win/loss data from the 2011 Major League Baseball season. Specifically, the file data/mlb_nl_2011.txt contains data about each National League team. Each line contains a team name fol- lowed by the number of wins and number of losses during the 2011...

  • C++ 3. Write a program that reads integers from a file, sums the values and calculates...

    C++ 3. Write a program that reads integers from a file, sums the values and calculates the average. a. Write a value-returning function that opens an input file named in File txt. You may "hard-code" the file name, i.e., you do not need to ask the user for the file name. The function should check the file state of the input file and return a value indicating success or failure. Main should check the returned value and if the file...

  • C++ Write a program that keeps track of inventory The data is located in the file Inventory.txt. ...

    C++ Write a program that keeps track of inventory The data is located in the file Inventory.txt. While the program is running, the information should be stored in a linked list. The information for each item needs be stored in a struct The definition will be in a separate file called items.h The total inventory will be stored in a linked list The definition of the list class will be in a file called linkList.h The program should be able...

  • The following is a sample inventory in C++, i want to ask the user to input a item number for removing from inventory. //CPP #include <iostream> #include <fstream> #include <cstdlib>...

    The following is a sample inventory in C++, i want to ask the user to input a item number for removing from inventory. //CPP #include <iostream> #include <fstream> #include <cstdlib> #include <iomanip> #define MAX 1000 using namespace std; //Function to Add a new inventory item to the data into the array in memory void addItem(string desc[],string idNum[], float prices[], int qty[],int &num) { cout<<"Enter the names:"; cin>>desc[num]; cout<<"Enter the item number:"; cin>>idNum[num]; cout<<"Enter the price of item:"; cin>>prices[num]; cout<<"Enter the...

  • In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, t...

    In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, then present a menu to the user, and at the end print a final report shown below. You may(should) use the structures you developed for the previous assignment to make it easier to complete this assignment, but it is not required. Required Menu Operations are: Read Students’ data from a file to update the list (refer to sample...

  • C++ Data Structure Write a program to read a list of students from a file and...

    C++ Data Structure Write a program to read a list of students from a file and create a list. The program should use a linked list for implementation. Each node in the linked list should have the student’s name, a pointer to the next student, and a pointer to a linked list of scores. There may be up to four scores for each student.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT