Computer Science: Bank Transaction Algorithm and Flowchart

Verified

Added on  2022/11/27

|9
|898
|63
Homework Assignment
AI Summary
This assignment presents solutions for two computer science problems. The first problem involves creating an algorithm and a flowchart for a bank transaction system, where a bank assistant enters a code (D, W, C, or T) to initiate a deposit, withdrawal, balance consultation, or transfer, respectively. The solution includes the algorithm, a flowchart, and a description of the process, addressing invalid inputs. The second problem requires the creation of an algorithm, flowchart, and C code to calculate the average of integers from 55 to a user-defined number 'n'. The solution handles the case where 'n' is less than or equal to 55, displaying an error message. The provided C code implements the average calculation using a loop and conditional statements. A detailed description is also included, explaining the logic behind each step of the algorithms and the functionality of the provided code.
Document Page
Computer Science Techniques
Algorithms
Student ID:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1. A client arrives to the bank and he needs to make a transaction from his
account. The bank assistant will enter the code and the transaction will be
displayed.
Create an algorithm and a flowchart in which the bank assistant enters the
code D as deposit, W as withdrawal, C as balance consultation, T as
transfer to another account.
The code must be entered and the transaction must be displayed.
Solution:
Document Page
Flowchart:
Yes
No
Yes
No
Yes
No
Yes
No
Start
Read ‘n’
n=’D’?
n=’W’
?
n=’C’?
n=’T’? Display ‘Transfer to
another account’
Display ‘Balance
Consultation’
Display ‘Withdrawal’
Display ‘Deposit’
Display ‘Invalid’
Stop
Stop
Stop
Stop
Stop
Document Page
Algorithm:
Step 1: Start
Step 2: Read a character ‘n’ from the user
Step 3: If n=’D’, then go to step 8.
Step 4: If n=’W’, then go to step 10.
Step 5: If n=’C’, then go to step 12.
Step 6: If n=’T’, then go to step 14.
Step 7: Display ‘Invalid’ and Go to Step 16
Step 8: Display a message ‘Deposit’
Step 9: Go to Step 16
Step 10: Display a message ‘Withdrawal’
Step 11: Go to Step 16
Step 12: Display a message ‘Balance Consultation’
Step 13: Go to Step 16
Step 14: Display a message ‘Transfer to another account’
Step 15: Go to Step 16
Step 16: Stop
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
2. Create an algorithm and a flowchart to calculate the average of integer
number, from 55 to n
Flow Chart :
Yes
No
No
Yes
Start
Read Number n
n<=55 Display message “error”
Stop
s=0
i=55
i<=n?
a=s/(n-54)s=s+i
i=i+1
Display the value of a
Stop
Document Page
Algorithm:
Step 1: Start
Step 2: Read a number ‘n’ from the user
Step 3: If n<=55, then go to step 12.
Step 4: Put s=0 and i=55.
Step 5: If i<=n, go to step 9.
Step 6: Assign a = s/(n-54)
Step 7: Display the value of a
Step 8: Go to Step 13
Step 9: Put s=s+i and i=i+1.
Step 11: Go to Step 5.
Step 12: Display a message ‘Error’
Step 13: Stop
C Code:
#include <stdio.h>
int main()
{
int i,n;
float a,s=0;
printf("enter n");
scanf("%d",&n);
if(n<=55)
printf("error");
else
{for(i=55;i<=n;i++)
{s=s+i;
}
Document Page
a=s/(n-54);
printf("\n %f",a);
}
return 0;
}
Description:
660
In task 1, we are accepting a charácter from the user. Base don the value stored in
that charater, we have to print a message on the screen. 4 cases are given to us. If
any carácter other than the cases mentioned is entered, then there is a message
invalid or error on the screen. The various cases are checked one by one.
Whenever a case matches the given charácter, the message relevant to that
charácter is printed on the screen.
For Example :
If user enters ‘E’, then it shows invalid on screen.
In task 2, we are accepting a number from the user. If the number is less than or
equal to 55, then we display an error or invalid message. If the number is greater
than 55, then we have to print the average of the integers from 55 to that number.
For this, we first add all the numbers from 55 to n, where n is the number entered
by the user. Next, we divide the sum by the number of terms which can be found
using the formula ( n – 54 ) .
For example:
If the user enters n = 57
Then sum = 55 + 56+ 57 = 168
Average will be calculated by dividing this sum with ( n – 54 ) = 57 – 54 = 3
Average = 168 / 3 = 56
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Suppose the user enters n = 34, then the message of error / invalid is printed on
the screen.
References:
Document Page
1. A. AHO, J. E. HOPCROFT, AND J. D. ULLMAN. The Design and Analysis of
Algorithms, Addison-Wesley, Reading, MA, 1975.
2. S. DASGUPTA, C. PAPADIMITRIOU, AND U.
VAZIRANI. Algorithms, McGraw-Hill, New York, 2008.
chevron_up_icon
1 out of 9
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]