.

Monday, April 1, 2019

Principles Of Procedural Programming Computer Science Essay

Principles Of adjectival Programming Computer Science riseProcedural programming is the most natural way of telling a computer what to do as the computer processors own language and car code is procedural. It is also referred as structured or modular programming. Procedural programming is performed by telling the computer what to do and how to do it finished a list of step-by-step instructions. Therefore, procedural programming involves procedures, which implies that there be steps that need to be followed to complete a specific job. For physical exertion construe a number, add 7 or scupper a specific message. Procedural programming is quite straightforward and efficient as more than often to begin with, the program is written in a common and plain language by applying logic before actually writing the code.The main features of procedural programming is that it is relatively easy to read and write program code and maintain program code as numerous procedures can be debugge d separately. Furthermore, large programs argon divided into little ones and that most of the data is sh ared and can therefore be reached from whatsoever other point within the program.Conclusively, taking into account that the main exampleistics of procedural programing being sequential logic, simplicity, easy implementation of compilers and interpreters, exponent to introduce use of the same code in the program by trading it instead of copying, ease with which the program flow can be tracked, ability to be strongly modular or structured, it can definitely be said that procedural programming is an inherent stepping stone towards learning raise programming skills.2. Implementing Procedural Programming Solutions.An algorithm can be delineate as a set of steps for performing a task that can be written down and implemented. An algorithm details how to abrasion with known discipline specified in the problem and how to use that information to reach a solution. In this partic ular task, the following algorithm use pseudo code has been developed a program which will befriend a small High Street Curry House trade their business operations.Algorithm using pseudo codeShow Login and electric receptacle ( Press 1 to Login/ else exit) orison monthly salary and other income figure and intro essential IncomeRequest All Personal Expenses ( i.e. college fees/ drive/ nutriment/ plump/entertainment/phone bill/ gas bill/electrical energy bill/ TV license/ council tax/ club membership and beneficence contribution and any other expenses)Calculate all expenses and display Total ExpensesCalculate and Display Balance (Total Income Total Expenses)If Balance is positive display credit amount and if negative display no more capital available.Diagram 1 Flowchart illustrating Algorithms Logical Flow Functions.STARTIF 1ORIF 2Salary + otherwise Income = Total Income DisplayRequest Salary Other incomeLoginRequest all ExpensesCalculate Total Expenses DisplayTotal I ncome Total Expenses = BalanceIf Balance is +ve (Balance 0)If Balance is -ve(Balance Display You are in CreditEXITNo More Funds forthcoming3 Implement Procedural Programming Solutionusing establishmentusing System.Collections.Genericusing System.Linqusing System.Textnamespace Unit18_CW_ID10571class Programstatic demoralize Main(string args)double monthlySalary, otherIncome, totalIncome,balance/*************************************************************************************************************************************About This program answers Task 3 of the Coursework for Unit18_Procedural Programming,BTEC HND in reason and Systems Development (CSD). Icon College of Technology and Management.Date 10.04.2013By Ibrahim Khan Mahomudally . disciple ID 10571Tutor Y M Gebremichael*************************************************************************************************************************************/Console.WriteLine( **************************************** ************************************** n)Console.WriteLine( Profit Loss Accounting 2013 )Console.WriteLine(tttt Menunn)Console.WriteLine(tttt 1. Loginnn)Console.WriteLine(tttt 2. Exitnn)Console.WriteLine(ttt To Login delight Press 1nn)Console.WriteLine(ttt To Exit Please Press 2nn)Console.WriteLine( ****************************************************************************** )int Menu = int.Parse(Console.ReadLine())if (Menu == 1)// stimulus income// rate total income and displayConsole.WriteLine(************************* All income***************************************)Console.WriteLine(Enter Monthly Salary )monthlySalary = double.Parse(Console.ReadLine())Console.WriteLine(Enter Any Other Income)otherIncome = double.Parse(Console.ReadLine())totalIncome = monthlySalary + otherIncomeConsole.WriteLine(Total Income = + monthlySalary + + + otherIncome + = + totalIncome)/******************************************************************************///input expenses//calculate tot al expenses and displayConsole.WriteLine(************************* All Expenses***************************************)double totalExpenses, rent, collegeFees, food, travel, entertainment, phonebill, gasbill, electricitybill,tvlicense, counciltax, clubmembership, charitycontribution, anyotherexpensesConsole.WriteLine(Enter College fees)collegeFees = double.Parse(Console.ReadLine())Console.WriteLine(Enter Rent)rent = double.Parse(Console.ReadLine())Console.WriteLine(Enter Food)food = double.Parse(Console.ReadLine())Console.WriteLine(Enter Travel)travel = double.Parse(Console.ReadLine())Console.WriteLine(Enter Entertainment)entertainment = double.Parse(Console.ReadLine())Console.WriteLine(Enter Phone Bill)phonebill = double.Parse(Console.ReadLine())Console.WriteLine(Enter Gas Bill)gasbill = double.Parse(Console.ReadLine())Console.WriteLine(Enter Electricity Bill)electricitybill = double.Parse(Console.ReadLine())Console.WriteLine(Enter TV License)tvlicense = double.Parse(Console.ReadLi ne())Console.WriteLine(Enter Council Tax)counciltax = double.Parse(Console.ReadLine())Console.WriteLine(Enter Club Membership)clubmembership = double.Parse(Console.ReadLine())Console.WriteLine(Enter Charity Contribution)charitycontribution = double.Parse(Console.ReadLine())Console.WriteLine(Enter Any Other Expenses)anyotherexpenses = double.Parse(Console.ReadLine())totalExpenses = collegeFees + rent + food + travel + entertainment + phonebill + gasbill +electricitybill + tvlicense + counciltax + clubmembership + charitycontribution + anyotherexpensesConsole.WriteLine(Total Expenses = + totalExpenses)Console.WriteLine(************************* Balance***************************************)//work out balance and display pertinent messagebalance = totalIncome totalExpensesConsole.WriteLine(Balance = + balance)if (balance = 0)Console.WriteLine( You Are In Credit by + balance)elseConsole.WriteLine(( No More Funds Available)else if (Menu == 2)Environment.Exit(1)elseConsole.WriteLi ne(Enter a number from the batting order)// this should return back to the menu againConsole.ReadLine()4 Testing Procedural Programming Solutions.Below are enclosed screenshots of the above-designed program demonstrating that every aspects of program is tested and compared against the design specification.Screenshot 1 Menu Options.Main menu presenting the user with the following optionsPress 1 to LoginPress 2 to ExitScreenshot 2 Request for Income.When 1 is pressed, user is requested to start entering figures for incomesScreenshot 3 Total Income.When all incomes are entered, Total Income is calculated and displayed.Screenshot 4 Input Expenses.User is requested to input figures for all expenses.Screenshot 5 Total Expenses, Positive Balance and Message.Total Expenses is calculated and displayed. Balance is obtained and if the solvent is positive, You Are In Credit message displayed.Screenshot 6 Negative Balance Relevant Message.Total Expenses is calculated and displayed. Balance is obtained and if result is negative,No More Funds Available message displayed4b Difference amidst syntax error and semantic errorsyntax is the required grammar and punctuation of the language while semantics is all about meaning, that is, what the statements do, what the programs do. Applying the correct syntax is essential as if non done properly, the program wont run. The syntax of a language greatly affects how easy it is to write, read and understand programs. Syntax errors ordinarily decease when program statements do not conform to the rule of the language. Therefore, Syntax errors occur during the parsing of input code, and are the result of grammatically improper statements. just about examples of syntax errors are misspelled keywords, unmatched quotation marks, missing semicolon, illegal character in the input, missing operator, two operators in a row, two statements on the same line with no intervening semicolon, unbalanced parentheses, misplaced uncommunicative word etc.semantic errors occur when the form of the elements in a statement is correct but the elements are not effectual for its use. Semantic errors are normally detected at compile time. Semantic errors occur during the execution of the code, after it has been parsed as grammatically correct. These errors have to do not with how statements are constructed, but with what they mean. Regular examples of sematic errors are such things as incorrect variable types or sizes, non-existent variables, subscripts out of range, specifying the wrong number of arguments for a function, using numeric variable name where only character variable is valid and non-existent references.

No comments:

Post a Comment