Tuesday, June 4, 2019

Principles Of Procedural Programming Computer Science Essay

Principles Of procedural Programming Computer Science Essayadjective broadcastming is the most natural way of sex act a computer what to do as the computer processors own style and machine 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 through a list of step-by-step instructions. Therefore, procedural programming involves procedures, which implies that there are steps that need to be followed to complete a specific task. For example read a number, add 7 or display a specific essence. 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 respect program code as numerous procedures can be debugged separately. F urthermore, large programs are divided into smaller ones and that most of the data is shared and can accordingly be reached from any other point within the program.Conclusively, taking into account that the main characteristics of procedural programing being sequential logic, simplicity, easy implementation of compilers and interpreters, faculty to make use of the same code in the program by calling it instead of copying, ease with which the program flow can be tracked, world power to be strongly modular or structured, it can definitely be said that procedural programming is an essential stepping stone towards learning further programming skills.2. Implementing Procedural Programming Solutions.An algorithm can be defined as a set of steps for performing a task that can be written down and implemented. An algorithm details how to start with known information specified in the problem and how to use that information to reach a solution. In this particular task, the following algorit hm using pseudo code has been developed a program which will help a small High highroad Curry House manage their business operations.Algorithm using pseudo codeShow Login and Exit ( Press 1 to Login/ else exit)Request monthly compensation and other incomeCalculate and Display perfect IncomeRequest All Personal Expenses ( i.e. college fees/ convey/ food/travel/ cheer/phone invoice/ gas bill/electricity bill/ TV license/ council tax/ club membership and charity 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 funds available. diagram 1 Flowchart illustrating Algorithms Logical Flow Functions.STARTIF 1ORIF 2Salary + former(a) Income = Total Income DisplayRequest Salary Other incomeLoginRequest all ExpensesCalculate Total Expenses DisplayTotal Income Total Expenses = BalanceIf Balance is +ve (Balance 0)If Balance is -ve(Balance Display You are in Credit scragNo More money Available3 Implement Procedural Programming Solutionusing Systemusing System.Collections.Genericusing System.Linqusing System.Textnamespace Unit18_CW_ID10571 family Programstatic void Main(string args)double monthlySalary, otherIncome, totalIncome,balance/*************************************************************************************************************************************About This program answers Task 3 of the Coursework for Unit18_Procedural Programming,BTEC HND in Computing and Systems Development (CSD). Icon College of Technology and Management.Date 10.04.2013By Ibrahim Khan Mahomudally . Student ID 10571Tutor Y M Gebremichael*************************************************************************************************************************************/Console.WriteLine( ****************************************************************************** n)Console.WriteLine( Profit Loss Ac counting 2013 )Console.WriteLine(tttt Menunn)Console.WriteLine(tttt 1. Loginnn)Console.WriteLine(tttt 2. Exitnn)Console.WriteLine(ttt To Login Please Press 1nn)Console.WriteLine(ttt To Exit Please Press 2nn)Console.WriteLine( ****************************************************************************** )int Menu = int.Parse(Console.ReadLine())if (Menu == 1)// stimulant income//calculate 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 total expenses and displayConsole.WriteLine(************************* All Ex penses***************************************)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.ReadLine())Console.WriteLine(Enter Council Tax)counciltax = double.Parse(Consol e.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 relevant 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.WriteLine(Enter a number from the menu)// this should return back to the menu agai nConsole.ReadLine()4 Testing Procedural Programming Solutions.Below are enclosed screenshots of the above-designed program demonstrating that both 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, drug 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 result 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 D ifference amid 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 not 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 usually occur 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 incorrect statements. Some examples of syntax errors are misspelled keywords, grotesque quotation marks, missing semicolon, illegal character in the input, missing operator, two operators in a row, two statements on the same line with no step in semicolon, unbalanced parentheses, misplaced reserved word etc.Semantic errors occur when the form of the elements in a statement is correct but the elements are not valid 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

Note: Only a member of this blog may post a comment.