Write a multi-module C program to manage an auto-parts database for a manufactory.
help translate the bash script into c

#! /bin/sh
#Project 2 CSC 3320
#echo menu test program
stop=0                     # reset loop termination flag.
while test $stop -eq 0     # loop until done.
do
 cat << ENDOFMENU             # display menu.
Main Menu
 (e) Edit Submenu
 (r) Report Submenu
 (q) Quit
ENDOFMENU
 echo -n 'your choice?'     # prompt.
 read reply                  # read response.
 echo
 case $reply in              # process response.
   "e")
     echo "Edit Submenu:"
     ./EditSubmenu.sh                # go to Edit submenu
     ;;
   "r")
     echo "Report Submenu:"
     ./ReportSubmenu.sh             # go to report submenu
     ;;
   "q")
     stop=1                  # set loop termination flag.
     ;;
   *)                        # default.
     echo illegal choice     # error.
     ;;
 esac
done


#!/bin/sh
#Project1  add submenu
echo -n "Name:"               #use if here to make sure the part is not there
read name
echo -n "Operator's Name:"
read operator
echo ${name}:in:$date:${operator} >> part.txt
echo "A new auto part is added into your data book."


#!/bin/sh
#Project1 delete submenu
echo -n "Name:"
read name
sed "/^${name}:/d"  part.txt >  parttemp.txt
cp parttemp.txt part.txt
rm parttemp.txt
echo "$name is removed from your part database."

#!/bin/sh
#project1 display submenu
echo -n "Name:"
read name
egrep -i "^$name" part.txt | awk -F: -f display.awk


#!/bin/sh
#project1 return submenu
echo -n "Name:"
read name
grep -i "$name" part.txt | sed s/out/in/g    part.txt

[asahib1@qubit ~]$ vi checkout.sh
#!/bin/sh
#project 1 checkout part submenu
echo -n "Name:"
read name
echo -n "Borrower's name:"
read borrower
borrower=$borrower
egrep -i "$name" part.txt | sed s/in/out/g   part.txt

{
printf "%s:%s:%s:%s:%s\n\n", $1,$2,$3,$4,$5;
}

#!/bin/sh
#echo submenu test program
stop=0                     # reset loop termination flag.
while test $stop -eq 0     # loop until done.
do
 cat << ENDOFSUBMENU             # display menu.
Edit Submenu
 (a) Add an auto part
 (p) Display an auto part
 (i) Return an auto part
 (o) Check an auto part
 (d) Delete an auto part
 (q) Return to main Menu
ENDOFSUBMENU
 echo -n 'your choice?'     # prompt.
 read reply                  # read response.
 echo
 case $reply in              # process response.
    "a")
      echo "Add an auto part:"
      ./add.sh                # go to add submenu
      ;;
    "p")
      echo "Display an auto part:"
      ./display.sh             # go to display submenu
      ;;
    "i")
      echo "Return an auto part:"
      ./return.sh             # go to return submenu
     ;;
    "o")
      echo "Check an auto part:"
      ./checkout.sh            # go to check submenu
     ;;
    "d")
      echo "Delete an auto part:"
      ./delete.sh            # go to delete submenu
     ;;
    "q")
      stop=1
                           # go to Main menu
     ;;
    *)                        # default.
      echo illegal choice     # error.
      ;;
 esac
 done


#! /bin/sh
# menu test program
stop=0                     # reset loop termination flag.
while test $stop -eq 0     # loop until done.
do
 cat << ENDOFMENU             # display menu.
Report Submenu:
 (n) Sort by Name
 (o) Sort by Operator's name
 (s) Sort by Status
 (q) Return to Main Menu
ENDOFMENU
 echo -n 'your choice?'     # prompt.
 read reply                  # read response.
 echo
 case $reply in              # process response.
   "n")
     sort -t: +0 -1 part.txt | awk -F: -f display.awk
     ;;
   "o")
     sort -t: +1 -2 part.txt | awk -F: -f display.awk
     ;;
   "s")
     sort -t: +2 -3 part.txt | awk -F: -f display.awk
     ;;
   "q")
     stop=1                  # set loop termination flag.
     ;;
   *)                        # default.
     echo illegal choice     # error.
     ;;
 esac
done

Recommended Answers

All 4 Replies

the program should be like
This is a simplified industrial project. Write a multi-module C program to
manage an auto-parts database for a manufactory. The manufactory has several
departments, each of which focuses on the production of a specific auto part. The
script should allow the staffs to add/delete auto parts to/from the database,
checkout /return back auto parts, display auto parts, and print sorted reports.
Each function is described as follows.
• Add auto parts: Add a record of an auto part such as part name,
operator’s name, status, etc. into the database.
• Delete auto parts: Delete the specified part from the database.
• Checkout: A department can checkout an auto part from the database. For
example, the department producing bumpers needs screws which are
produced in another department.
• Return: A department can return the checked out auto parts, i.e., the style
of the checked out auto part does not meet the requirement of the
department.
• Display auto parts: Display the specified auto part.
• Print sorted reports: Generated reports of sorted auto parts.
The script should be menu-based with the following options:
Main Menu:
(e) Edit Submenu
(r) Report Submenu
(q) Quit
Edit Submenu:
(a) Add an auto part
(p) Display an auto part
( i) Return an auto part
(o) Checkout an auto part
(d) Delete an auto part
(q) Return to Main Menu
Report Submenu:
(n) Sort by Name
(o) Sort by Operator’s name
(s) Sort by Status
(q) Return to Main Menu

i can nt belive no one can help me in this. No one knows c in here

commented: We don't do your homework. Read the forum rules. -1

i can nt belive no one can help me in this. No one knows c in here

We don't do homework. Read the forum rules. And what you believe or do not believe is irrelevant.

We don't do homework. Read the forum rules. And what you believe or do not believe is irrelevant.

alli need is a lil help. I never done anything in c but i wrote the code script in bash, but can nt ever get in c

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.