Looking for Python code for below problem: ------------------------------------------------------...

Looking for Python code for below problem:

------------------------------------------------------------

The Creative Door Logistics is a successful name in the e-commerce vertical. The company’s development team is just trying to implement their online invoice management application, which will help its customers to purchase and get the invoice generated for the items in the shipping list. To begin with, they start with few modules of the application. Help the development team for writing codes for login validation, making a purchase and displaying the purchase details.

Initially, the application reads the username from the user, if invalid credentials are given then print “Invalid Username and Password” and terminate the application.

Once a valid Username and Password is given, the application should print “Login Successful” and then prompt the item to be purchased.

Display “Item not present” if the item number is not present in the item file in the main. If the valid item number is given, the application should prompt for the quantity of the item to be purchased. Use the prompt “Do you want to add one more item?(Yes or No)” to add more items to the list.

When the user chooses “No” from the above prompt, the list of items along with item number, item name, quantity and the cost is displayed with the total cost of the shopping list.

When the user selects Exit, the application terminates

Note:

The list of registered users is available in an xml file names userpass.xml

The list of items is available in an xml file named item.xml

Method Description:

Method Name

Arguments

Return Type

Description

validateUsernamePassword()

Users file name(userFile), userName, password

userFile- string

username- string

password- string

Boolean

This function validates the username and password.

Print “Login Successful” and return True, if valid user; else print “Invalid username and password” and return False”

checkItemPresent()

Item File name(itemFile), itemNo.

itemFile- string

itemNo- integer

Boolean

This function will check whether the itemNo is present in the itemFile or not. Return True if the item is present, else return False.

purchaseItem()

Item File name(itemFile), username, itemNo, quantity.

itemFile-string

username- string

itemNo- integer

quantity-integer

List

This function checks whether the given item has the specified quantity present. If present, build a list with elements- itemNo, itemName, quantity and cost, and return the list. If the specified quantity is not present, print “The required quantity is not available” and return an empty list.

calculateAmount()

purchaseList

purchaseList- list of purchased items

Integer

This function calculates the total cost for the purchased items.

userpass.xml

<userList>

  <user>

     <username>Soukhya</username>

     <password>soky</password>

</user>

<user>

      <username>Sahana</username>

      <password>sana</password>

</user>

<\userList>

item.xml

<itemList>

    <item>

        <itemNo>51</itemNo>

        <name>Tops</name>

        <cost>700</cost>

      <quantity>50</quantity>

   </item>

   <item>

      <itemNo>52</itemNo>

      <name>Shoes</name>

      <cost>1800</cost>

      <quantity>65</quantity>

   </item>

</itemList>

Sample input and output 1:

Enter username:

Sahana

Enter password:

soanaa

Invalid Username and Password

Sample input and output 2:

Enter username:

Sahana

Enter password:

sana

Login successful

1.Purchase Item

2.Exit

Enter your choice:

1

Enter item number:

51

Enter quantity of item:

200

The required quantity is not available.

Do you want to add one more item?(Yes/No):

Yes

Enter item number:

52

Enter the quantity of item:

2

Do you want to add one more item?(Yes/No):

No

Item No Name Quant Cost

52 Shoes 2 1800

Total Cost = 3600

1.Purchase item

2.Exit

Enter your choice:

2

Sample input output 3:

Enter username:

Sahana

Enter password:

sana

Login Successful

1.Purchase item

2.Exit

Enter your choice:

1

Enter item number:

501

Item not present

Enter item number:

51

Enter quantity of item:

1

Do you want to add one more item?(Yes/No):

Yes

Enter the item number:

52

Enter quantity of item:

2

Do you want to add one more item?(Yes/No):

No

Item No Name Quant Cost

51 Tops 1 700

52 Shoes 2 1800

Total cost = 4300

1.Purchase item

2.Exit

Enter your choice:

2

-------------------------------------------

Thanks in advance.

Solved
COMPUTER SCIENCE 1 Answer Tarek Shohdy