# SOLVED CS402 Assignment 2 Solution and Discussion

• ``````Assignment No. 02
``````

Semester: Spring 2020
Theory of Automata – CS402
Total Marks: 20

Due Date: June 15, 2020

Objectives:
Objective of this assignment is to assess the understanding of students about the concept of FA, NFA, DFA and conversion from Regular expression to NFA and NFA to FA and DFA.

Instructions:

1. You should consult the recommended books, PowerPoint slides and audio lectures to clarify your concepts.
2. You are supposed to submit your assignment in .doc format. Any other formats like scan images, PDF, zip, rar and bmp etc will not be accepted.
3. It should be clear that your assignment will not get any credit if:
• The assignment is submitted after due date.
• The assignment is copied from Internet or from any other student.
• The submitted assignment does not open or file is corrupt.

Note: No assignment will be accepted after the due date through email in any case (load shedding, server down, internet malfunctioning etc.).
It is recommended to upload solution file at least two days before its closing date.

For any query about the assignment, contact at [email protected]

Question: Marks = 20
Q. Write a regular expression for a language over alphabet L = {a,b} accepting all strings and ending with b only. Convert the given regular expression into NFA and then convert the NFA to DFA.

``````                                                                                                                        [4 + 8 + 8  = 20 marks]
``````

BEST OF LUCK

• Develop a program that calculates Loan in C++. Your program should satisfy the following requirement:
User Input:
1 User is asked to enter name.
2 User is asked to enter number of dependent with range (0-5).
3 User is asked to enter status i.e. (Permanent or Probation).
4 User is asked to enter Salary.
5 User is asked to enter Duration at Job (in years):
o <1
o 1-2
o 2-4
o 4-7
o >7
6 User is asked how much loan is required.

Criteria:
 Loan can be given if and only if a person is on Permanent job for more than 1 years.
 Minimum salary from which a loan can be given is 35,000 per month for a person having no
dependent. Minimum salary requirement increases by 20,000 per dependent.
 If years of services is from 1 to 2 years, then max loan amount can be up to 6 salaries.
 If years of services is from 2 to 4 years, then max loan amount can be up to 8 salaries.
 If years of services is from 4 to 7 years, then max loan amount can be up to 10 salaries.
 If years of services is from 7 to 10 years, then max loan amount can be up to 12 salaries.
 If years of services is more than 10 years, then max loan amount can be up to 24 salaries.
 Add 13% interest on the approved loan amount. This amount will be payable within 8 years’
time i.e. 96 months.
 If the money to lend is more than the lend amount, then calculate the difference and show it
properly.
 For unsuccessful Loan Application: Show Message: “CUSTOMER NAME, your lend
application has not been successful this time”.
 For Successful Loan Application: Show Message: “Congratulations CUSTOMER NAME, your
lend application is successful this time. Your monthly installment will be ______ Amount
Payable for 96 months”.

• Q. Write a regular expression for a language over alphabet L = {a,b} accepting all strings and ending with b only. Convert the given regular expression into NFA and then convert the NFA to DFA.
[4 + 8 + 8 = 20 marks]

A regular expression for a language over alphabet L = {a,b} accepting all strings and ending with b only is as given below:

RE = (a+b)* b

The above regular expression may be equivalent to the following NFA

The above NFA may be equivalent to the following DFA

5

2

1

1

3

1

5

1
| |