Question

In: Computer Science

DO NOT ANSWER THIS QUESTION[Write a program that the owner of Chica Chic could use to...

DO NOT ANSWER THIS QUESTION[Write a program that the owner of Chica Chic could use to store data about her inventory in a text file. The program should prompt her to input the name, cost price, and quantity of each item of inventory. Each of these three data has to be written to its own line in the file. The program should loop to enable any number of inventory items to be stored and end when the item name is left blank (see Sample Output. User inputs are shown in blue). The program should end by closing the file and printing a file status message. Sample Output Enter the name of the inventory item or ENTER to quit tops Enter the cost price of this item 24.99 Enter the quantity in stock of this item 10 A record was written to file Enter the name of the inventory item or ENTER to quit shorts Enter the cost price of this item 29.95 Enter the quantity in stock of this item 12 A record was written to file Enter the name of the inventory item or ENTER to quit sandals Enter the cost price of this item 19.79 Enter the quantity in stock of this item 8 A record was written to file Enter the name of the inventory item or ENTER to quit The file was created successfully and closed] DO NOT ANSWER THIS QUESTON

Now write another program that reads her inventory file, displays all data for each item, and reports on the inventory value. The cost value of each item and the cost value of the total inventory should be reported. Strive to duplicate the Sample Output below.
Sample Output
Chica Chic Inventory

tops, $24.99 each, 10 in stock, value $249.90
shorts, $29.95 each, 12 in stock, value $359.40
sandals, $19.79 each, 8 in stock, value $158.32
End of file
Total inventory value $767.62

Solutions

Expert Solution

********This require a lot of effort so please give a thumbs up if you are satisfied with the content***********

You have not specified any programming language so I have written it using python for ease and less lines of code

Storing Inventory File Code:

import os.path

# In below path change the ----- text  \Users\----\Desktop to your username so that
# the file saves on your desktop
savePath = "C:/Users/THE__INFINITY/Desktop"
nameOfTheFile = "Inventory"
completeName = os.path.join(savePath, nameOfTheFile + ".txt")
f = open(completeName, "a+")

# Code for Storing the inventory
while (1):
    print("Enter the name of the inventory item or ENTER to quit")
    name = input()
    if (len(name) > 0):
        print("Enter the cost price of this item:")
        cost = input()
        cost = float(cost)
        print("Enter the quantity in stock of this item")
        quantity = input()
        quantity = float(quantity)
        value = str(format("%.2f" % (quantity * cost)))
        f.write(name + " $" + str(cost) + " value:" + value + "\n")
    else:
        print("The file was created successfully and closed")
        break
f.close()

*******The file will be created on desktop please go through the comments in the code to set the path where you want to store the file ******

Inventory Reading File Code:

import os.path
try:
    savePath = "C:/Users/THE__INFINITY/Desktop"
    nameOfTheFile = "Inventory"
    completeName = os.path.join(savePath, nameOfTheFile + ".txt")
    totalValue = 0
    f = open(completeName, "r")
    fileContents = f.read()
    inventory = fileContents.split("\n")
    print("Chica Chic Inventory")
    for eachRecord in inventory:
        value = eachRecord.split(":")
        if (len(value) == 2):
            print(eachRecord)
            totalValue = totalValue + float(value[1])
    print("End of file")
    print("Total inventory value $%.2f" % totalValue)
    f.close()
except OSError:
    print("file not found please create a file first")


Related Solutions

C++ DO not use arrays to write this program. Write a program that repeatedly generates three...
C++ DO not use arrays to write this program. Write a program that repeatedly generates three random integers in the range [1, 100] and continues as follows: If the right-most digit of all the three integers is equal, the program displays them in ascending order on the screen and continues. If the generated integers have different right-most digits, they are not displayed and the program continues. The program terminates once the right-most digits of all the three random numbers are...
use linux or c program. please provide the answer in details. Write a program that will...
use linux or c program. please provide the answer in details. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally...
Use the information below to answer the question that follows.Sosiol Distan Singh the owner of Esquire...
Use the information below to answer the question that follows.Sosiol Distan Singh the owner of Esquire Ltd is considering two technology investment options; Karantina and Barakoa which will require sh. 1,500,000 and sh. 200,000, respectively. The revenues for each option are as follows. Karantina (for year 1 to year 6) 100,000; 350,000; 450,000; 765,000; 1,335,000; 2,150,000. Barakoa (for year 1 to year 3) 300,000; 350,000; 500,000. The expenses increase yearly from the first year by 20% each subsequent year. The...
I do not understand this question could someone please answer and give meaning to this question....
I do not understand this question could someone please answer and give meaning to this question. MHC6305 Finanical Management. Compare and contrast cash accounting methodology and accrual accounting methodology in order to illustrate how each best works for different types of companies.
Write a C program with the following prompt *do not use gotostatement* "Write an interactive...
Write a C program with the following prompt *do not use goto statement* "Write an interactive program that implements a simple calculator. The program should allow the user to choose a binary arithmetic operation and enter two terms to which to apply the operation. The program should then compute the result and display it to the user. Your calculator will have two modes: double-precision mode and integer mode. Double-precision mode will do calculations and output using variables of type double....
DO NOT ANSWER THIS[1. Write a program named filemaker.py that will be used to store the...
DO NOT ANSWER THIS[1. Write a program named filemaker.py that will be used to store the first name and age of some friends in a text file named friends.txt. The program must use a while loop that prompts the user to enter the first name and age of each friend. Each of these entries should be written to its own line in the text file (2 lines of data per friend). The while loop should repeat until the user presses...
In C program, Use "do...while" and "for" loops to write a program that finds all prime...
In C program, Use "do...while" and "for" loops to write a program that finds all prime numbers less than a specified value.
Question 1 In this exercise, you are required to do a program analysis and write a...
Question 1 In this exercise, you are required to do a program analysis and write a program for a system that computes a speeding ticket cost. The charge is calculated as follows: P20 for every kilometre above the speed limit, plus P100 standard charge. E.g. If the speed limit is 60 km/hour and you are driving at 75 km/hour. The charge will be P400. If the speed is equal to or under the speed limit, then there is no charge....
Write this program in C++ language. Use the concept of structures. DO NOT use vectors. Q...
Write this program in C++ language. Use the concept of structures. DO NOT use vectors. Q (4) Create a structure called time. Its three members, all type int, should be called hours, minutes, and seconds. Write a program that prompts the user to enter a time value in hours, minutes, and seconds. This should be in 12:59:59 format. This entire input should be assigned first to a string variable. Then the string should be tokenized thereby assigning the 1st token...
CIT 149 JAVA 1 program question? Write a program that will use static methods as described...
CIT 149 JAVA 1 program question? Write a program that will use static methods as described in the specifications below. Utilizing the if and else statements, write a program which will calculate a commission based on a two-tiered commission plan of 3% and 7% paid on amounts of $15,000 or less, or over $15,000 in monthly sales by a sales force paid on a commission basis. Use the output specifications below. ? Specifications There will be two classes (separate files)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT