This is your chance to become the instructor. After learning the looping and inp
ID: 3904782 • Letter: T
Question
This is your chance to become the instructor. After learning the looping and input validation concepts, create a problem to give to your students to allow them to practice the looping and input validation concepts. The problem should include at least two different decision structures and a loop. The number of times to process the loop is stated in the problem definition. The decision structures should be chosen from the simple, combined, nested and CASE structures. Use the Programming Exercise problems at the end of Chapter 5 as an example.
The problem description should include:
The input into the problem.
The output from the problem.
The generic processing necessary to solve the problem. (do not give too much information away).
The solution should include:
Input validation statements
The solution should include the exact calculations need to solve the problem.
The solution cannot be similar to a problem posted by another student, located on the Internet or located in another textbook.
pseudocode, in while loop
Explanation / Answer
The Problem information is as follows:
The input: A data file containing the bank account information.Accounts are of different
types (like Savings Account, Checking Accounts).
The Output: Report on Number of Savings Account, Number of Checking accounts and their
total balances, avregae balance, maximum and minimum balance etc
Processing:
Read the file data
Consider valid account data
Separate different accounts
Calculate the sum of their balances
Calculate the average balnace for each type of account
Display the information
Solution:
1.The application should be able to read the csv file.
2.All the error checking should be done as per defined rules
3.The report should be generated in the defined format
4.Data display precisions need to be followed.
5.Interactive errors should be reported with proper messages
6.Integrity of the data should be maintaied while saving the data.
7. Calculation of the averageAccountBalance = (Sum of all the balances of a particular type of account)/(number of that type of account)
8. TotalAccountBalance = Sum of all the balances of each type of account.
9. To find maximum start with a default value and then traverse all the accounts and update the maximum value as per the comparison results
and same for minimum.
Input Validation:
1.Check for the filename (maximum length is 10 chars besides the csv extension)
2.account number (12 digits, first three entries are alphabets)
3.Name (Only alphabets are allowed)
4.Phone Number (7 digits must follow the format xxx-xxx-x)
pesudoCode:
Input filename
open the file
declare accounts[] array
Read the data in accounts and update numOfAccounts
declare numOfAccounts, numOfSavingActs, numOfCheckingActs, totalBalanceSavings, totalBalanceChecking, averageBalanceChecking
averageBalanceSavings, maximumSaavings, minimumSavings, maximumChecking, minimumChecking
for i = 1 to n:
if (Validate(account[i])):
if account[i].type == "Savings":
numOfSavingActs++
totalBalanceSavings = totalBalanceSavings + account[i].balance
if account[i].balance > maximumSavings:
maximumSavings = account[i].balance
if account[i].balance < minimumSavings:
minimumSavings = account[i].balance
if account[i].type == "Checkings":
numOfSavingActs++
totalBalanceSavings = totalBalanceSavings + account[i].balance
if account[i].balance > maximumSavings:
maximumSavings = account[i].balance
if account[i].balance < minimumSavings:
minimumSavings = account[i].balance
Display(Data)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.