OUTPUT: New Entry(S) Added in File Product.Dat

OUTPUT: New Entry(S) Added in File Product.Dat

Algorithm add_product()

INPUT: An non-empty file “product.dat”.

OUTPUT: New Entry(s) added in file “product.dat”.

{

Prod_code <- 0;

Prod_name;

Prod_picture;

Prod_price <- 0;

Prod_no <- 0;

Write(“How many products to be added”);

Read(prod_no);

For I <- 0 to prod_no, do

{

Read(prod_code, prod_name, prod_picture, prod_price);

Write in file(prod_code, prod_name, prod_picture, prod_price);

}

}

Algorithm modify_delete_product()

INPUT: An non-empty file “product.dat

OUTPUT: Modified Entry in file “Product.dat

{

P_code <- 0;

Write(“Enter the product code of the product to be modified”);

Read(p_code);

For all items in the list, do

{

If(p_code == prod_code), then

{

Write(“What do you want to modify”);

Write(“1. Product code”);

Write(“2. Product name”);

Write(“3. Product picture”);

Write(“4. Product price”);

Write(“5. Delete Product”);

Read(ch);

If(ch == 1), then

{

Read(new_code);

Delete_product(p_code);

Write in file(new_code, prod_name, prod_picture, prod_price);

}

If(ch == 2), then

{

Read(new_name);

Delete_product(p_code);

Write in file(new_code, new_name, prod_picture, prod_price);

}

If(ch == 3), then

{

Read(new_picture);

Delete_product(p_code);

Write in file(new_code, prod_name, new_picture, prod_price);

}

If(ch == 4), then

{

Read(new_price);

Delete_product(p_code);

Write in file(prod_code, prod_name, prod_picture, new_price);

}

If(ch == 5), then

{

Delete_product(p_code);

}

}

Else

Write(“Product not found!”);

}

}

Algorithm delete_product(p_code)

INPUT: An non-empty file “product.dat

OUTPUT: Deleted entry of product from the file “product.dat”

{

For all items in the list, do

{

If(p_code == prod_code), then

{

Delete(prod_code);

}

}

}

Algorithm report()

INPUT: An non-empty file “product.dat

OUTPUT: Product details is been displayed on screen.

{

Write(“Product Code Product Name Product Picture Product Price”);

Write(“------“);

For all items in the list, do

{

Write(prod_code, prod_name, prod_picture, prod_price);

}

}

Algorithm Customer_entry()

INPUT: An non-empty file “customer.txt

OUTPUT: New entry(s) in file “customer.txt”

{

Write(“NAME:”);

Read(c_name);

Write(“ADDRESS:”);

Read(c_add);

Write(“PHONE NUMBER:”);

Read(c_ph);

Write in file(c_name, c_add, c_ph);

}

Description:

  • Two files are present named “product.dat” and “customer.txt”.
  • “product.dat” contains product information like code,name, picture,price.
  • “customer.txt” contains customer information like name, address, phone number.
  • “write in file”is used to store the output in file (product.dat or customer.txt).