Help
can you do this?
C programming
Overview
In this program, you will be taking product information in from a file, taking in sales information from a file, and calculating the new inventory quantity. Your program should also output the inventory information to a new file at the user's request.
Requirements:
Take in via command line arguments the names of the product info and sales files. Read in the information into an array of structures and a 2d array respectively. Calculate the remaining inventory based upon the number of items sold, and print a report. Finally, ask the user if they would like to output the information to a new file. If so, the output file should have the same format as the input product info file.
File Format
Product Info
Row 1: Number of products
Rows 2+: Product Name
Rows 3+: Quantity, MSRP, Sale Price
4
Mountain Dew 12
pack 50 4.99 3.99
Doritos 172 3.99 375
iPhone 11 43 699.99 699.99
Thin Mints 73 4 3.99
Sales
Row 1: Number of sales
Rows 2+: Number sold for each product
5
2 2 0 0
1 3 0 0
0 0 1 0
0 1 0 3
1 0 0 0
In the above file example, there were file sales. The columns represent each of the four products from this sample.
I have attached the code and screenshots, please have a look. I have commented the code.
----------------------------------------------------product_info.txt---------------------------------------------------------------------------------
4
Mountain Dew 12 pack
50 4.99 3.99
Doritos
172 3.99 3.75
iPhone 11
43 699.99 699.99
Thin Mints
73 4 3.99
----------------------------------------------------------product_info.txt screenshot-------------------------------------------------

-------------------------------------------------------sales_info.txt--------------------------------------------------------------------------
5
2 2 0 0
1 3 0 0
0 0 1 0
0 1 0 3
1 0 0 0
--------------------------------------------------------sales_info.txt screenshot--------------------------------------------------------

--------------------------------------------------------main.c----------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
//struct for product_info
struct product_info
{
char prod_name[50];
int quantity;
float msrp;
float sale_price;
int remaining_inventory;
};
int main(int argc, char** argv)
{
if(argc < 3) // Check for command line arguments
{
printf("Run as ./a.out product_info.txt sales_info.txt\n");
exit(1);
}
int number_of_products;
char temp[100];
FILE *inpfile;
inpfile = fopen(argv[1],"r"); // Reading the input file
fscanf(inpfile, "%d", &number_of_products); // first line in
product info file contains, Number of products
fgets(temp, 100, inpfile); //goto next line
struct product_info products[number_of_products]; // create array of structures
for(int i = 0; i<number_of_products; i++)
{
fgets(products[i].prod_name, 50, inpfile); //Get productname from
line
fscanf(inpfile, "%d %f %f", &products[i].quantity,
&products[i].msrp, &products[i].sale_price); //Get
Quantity, MSRP, Sale Price
fgets(temp, 100, inpfile); //goto next line
}
int number_of_sales;
inpfile = fopen(argv[2],"r"); // Reading the input file
fscanf(inpfile, "%d", &number_of_sales); // first line in sales
info file contains, Number of sales
fgets(temp, 100, inpfile); //goto next line
int sales_quantity[number_of_sales][number_of_products]; // create 2d array of sales quantity
for(int i = 0; i<number_of_sales; i++)
{
for(int j = 0; j<number_of_products; j++)
{
fscanf(inpfile, "%d", &sales_quantity[i][j]); // write to 2d
array from file
}
fgets(temp, 100, inpfile); //goto next line
}
for(int j = 0; j<number_of_products; j++) // Calculating
remaining inventory Column wise
{
int sold = 0;
for(int i = 0; i<number_of_sales; i++)
{
sold = sold + sales_quantity[i][j];
}
products[j].remaining_inventory = products[j].quantity -
sold;
}
int flag = 0;
printf("\n Do you want to create inventory file (Enter 1 if Yes, 0
if No):");
scanf("%d", &flag);
if(flag == 1)
{
FILE *outfile ;
outfile = fopen("inventory_info.txt", "w") ; // Creating output
file
fprintf(outfile,"%d\n", number_of_products);
for(int i = 0; i<number_of_products; i++)
{
fprintf(outfile,"%s", products[i].prod_name);
fprintf(outfile,"%d %f %f\n",
products[i].remaining_inventory, products[i].msrp,
products[i].sale_price);
}
printf("inventory_info.txt created successfully\n");
}
return 0;
}
------------------------------------------------------main.c screenshots----------------------------------------------------------



---------------------------------------------------------inventory_info.txt-----------------------------------------------------------------------
4
Mountain Dew 12 pack
46 4.990000 3.990000
Doritos
166 3.990000 3.750000
iPhone 11
42 699.989990 699.989990
Thin Mints
70 4.000000 3.990000
-------------------------------------------------inventory_info.txt screenshot---------------------------------------------------

------------------------------------------------------console screenshot-----------------------------------------------------------

------------------------------------------------------------------------------------------------------------------------------------------
I hope this will help you. Please feel free to comment.
Help can you do this? C programming Overview In this program, you will be taking product...
Can you help us!! Thank you!
C++
Write a program that can be used by a small theater to sell tickets for performances. The program should display a screen that shows which seats are available and which are taken. Here is a list of tasks this program must perform • The theater's auditorium has 15 rows, with 30 seats in each row. A two dimensional array can be used to represent the seats. The seats array can be initialized with...
Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...
Use a two-dimensional array to solve the following problem. A company has four salespeople (0 to 3) who sell five different products (0 to 4). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains the following: a) The salesperson number b) The product number c) The total dollar value of that product sold that day Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that...
In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast billing system. The program should do the following: Show the customer the different breakfast items offered by the restaurant. Allow the customer to select more than one item from the menu. Calculate and print the bill. Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item): Name Price Egg (cooked to order)...
(C++ programming) Need help with homework. Write a program that can be used to gather statistical data about the number of hours per week college students play video games. The program should perform the following steps: 1). Read data from the input file into a dynamically allocated array. The first number in the input file, n, represents the number of students that were surveyed. First read this number then use it to dynamically allocate an array of n integers. On...
In C++.
Write another program in file B2.cpp to calculate and print the total sales of each product by each salesperson. Read the sales slips from the file Salesslips.txt (or for partial points, in case your program Bl.cpp does not work correctly, from an array with the same data, initialized in your main program) and calculate the total sales of each product by each salesperson. Accumulate the total sales of each product by each salesperson in a two- dimensional array...
Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...
Need help with this programming please this is the instruction
my teacher provided
Write a C++ class called "Sales" and a main( ) function that uses the class. Also, write documentation of your project. Below is a specification of the class. . INTRODUCTION A company has four salespeople (1 to 4) who sell five different products ( to 5)1. Once a day each salesperson passes in a slip for each different type of product sold. Each slip contains: The salesperson...
For this program you create a program with multiple functions using C++ 1) You will need a function that creates an array of 100 random numbers that are generated between and including 20 and including 40. This must be a two dimensional array of 10 numbers in a row with a total of 10 rows. 2) A function that will store the array of random numbers in a data file called "rannum". 3) A function must then read the data...