Assignment 1 - 1618 C# Programming, Assignments of Computer Programming

D task has something wrong, fix it if u wanna get the D grade!

Typology: Assignments

2021/2022

Uploaded on 09/04/2023

ecco3kdaddy
ecco3kdaddy 🇻🇳

6 documents

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ASSIGNMENT 1 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 1: Programming
Submission date
Date Received 1st submission
Re-submission Date
Date Received 2nd submission
Student Name
Student ID
Class
Assessor name
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Student’s signature
Grading grid
P1
M1
D1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download Assignment 1 - 1618 C# Programming and more Assignments Computer Programming in PDF only on Docsity!

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 1: Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Student ID Class Assessor name Student declaration I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that making a false declaration is a form of malpractice. Student’s signature Grading grid P1 M1 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

  • Chapter 1: State your business problems to be solved (P)
      1. Definition of algorithms
      1. Characteristic of algorithm
      1. The steps of building application.......................................................................................................................
      1. My problem:
  • Chapter 2: Analyze the problem and design the solutions by the use of suitable methods (P)
      1. Analyze the business problem
      1. Design the algorithm
  • Chapter 3 – Demonstrate the compilation and running of a program (M)
      1. Coding:
      1. Screen when running my program:
      1. An explanation of how the source code is compiled and run in c#.
  • programming language. (D) Chapter 4 – Evaluate how the problem is solved from the designed algorithm to the execution by a specific
      1. Test case
    • specific programming language 2. Evaluate how the problem is solved from the designed algorithm to the execution program written by a
  • References
  • Figure 1: What is an algorithm Table of figure
  • Figure 2: The first-degree equation
  • Figure 3: Flowchart for finding solutions of first-degree equations
  • Figure 4: The code of my program
  • Figure 5: Enter a
  • Figure 6: Enter a = -
  • Figure 7: Print x...........................................................................................................................................................
  • Figure 8: When a = 0 & b = 0......................................................................................................................................
  • Figure 9: When a = 0 & b = 3......................................................................................................................................
  • Figure 10: Compilation process of C# code

ASSIGNMENT 1

Chapter 1: State your business problems to be solved (P)

1. Definition of algorithms Figure 1 : What is an algorithm ➢ An algorithm is a finite sequence of well-defined instructions, typically used to solve a class of specific problems or to perform a computation. (Wikipedia, 2021) ➢ In my opinion, an algorithm is a map containing paths (algorithms) that help us get to our destination. 2. Characteristic of algorithm ➢ An algorithm must possess following characteristics: - Definiteness: Each step must be precisely defined; the actions to be carried out must be rigorously and unambiguously specified for each case. - Finiteness: The algorithm must always terminate after a finite number of steps. - Precise and Effective: All operations to be performed must be suffciently basic that they can be done exactly and in finite length. - Implementation indpendent: An algorithm should have step-by-step directions, which should be independent of any programming code. (FPT Greenwich, 2021)

Purpose: Program is written to calculate “x” in a first-order equation. ➢ Algorithm: Using 2 conditional statements:

  • The first is to check a = 0, then it will give the solution and then terminate the program. If a is non-zero, the second conditional statement will be used.
  • The second is to compare “b”. If b = 0, then the equation has no solution, otherwise it is an equation with infinitely many solutions. Chapter 2: Analyze the problem and design the solutions by the use of suitable methods (P)

1. Analyze the business problem

a. Specifying the input requirements

➢ The chapter must deal with 3 conditions:

  • If a ≠ 0, the solution gives x = - b / a.
  • If a = 0 and b ≠ 0 output the equation has no solution.
  • If a = 0 and b = 0 output the equation has a multitude of solution. No Variable Data type Description 1 a float This variable stores the value of the coefficient a 2 b float This variable stores the value of the coefficient b

b. Specifying the output requirements

➢ The output of my program should be I number. Can be an integer can also be a real number.

There must also be an additional message if the equation has no solution or has infinitely many solutions. No Variable Data type Description 1 x float This variable stores the result of the 1st^ degree equation (ax + b = 0) with x = - b / a

c. Specifying the processing requirements

➢ The chapter must deal with 3 conditions:

  • If a ≠ 0, the solution gives x = - b / a
  • If a = 0 and b ≠ 0, the output the equation has no solution
  • If a = 0 and b = 0, the output the equation has a multitude of solutions.

2. Design the algorithm

a. What is a design?

➢ A design is a path from the problem to a solution in code.

b. The well-designed program is likely to be

➢ Easier to read and understand later

➢ Less of bugs and errors

➢ Easier to extend to add new features

➢ Easier to program in the first place

c. What is flowchart?

➢ Flowchart is a diagrammatic representation of an algorithm

  • It uses different symbols to represent the sequence of operations, required to solve a problem.
  • It serves as a blueprint or a logical diagram of a solution to a problem,

d. An introduction to first-order equations

➢ A first-degree equation is an equation of the form ax + b = 0. The equation has a unique solution

x = - b / a if a ≠ 0. The equation has no solution when a = b, b ≠ 0. The equation will have infinitely many solutions when a = b and b = 0.

e. Here is my flowchart description: The program I write is a first-degree

equation (ax + b = 0)

➢ At the beginning of my program. I declare two variables a and b. Variable a and b to store the

values of numbers a and b of a first-degree equation. Next, the program will print a message to enter 2 number a, b and ask the user to enter two numbers. After the user enters two numbers a, b, it will do a comparison a. If a ≠ 0 then it will go in the false direction to calculate x with x = - b / a, then print out x and end the program. If a = 0 then it will go to true and do b comparison. If b ≠ 0, the message “The equation has no solution” will be displayed then end program. If b = 0, the message “The equation has a multitude of solutions” is displayed then end program.

Figure 4 : The code of my program

2. Screen when running my program:

a. Start program Figure 5 : Enter a

Explain: The program will display the form of equation for the user to recognize, in parallel, asking the user to enter the coefficient a. b. Enter 2 (with a = - 2) Figure 6 : Enter a = - 2Explain: The program will store the value of the coefficient a in the variable a (Ex: a = - 2) ask the user to enter the value of coefficient b. c. Enter b (with b = 8) Figure 7 : Print x

➢ When the user enters a = 0 and b 0 (Ex: b = 3), the program will have infinite solution and print “This equation has no solution”.

3. An explanation of how the source code is compiled and run in c#.

Step-by-step process of C# compilation:Step 1: Write a C# code ➢ Step 2: Compile the code using a C# compiler ➢ Step 3: Now compiler checks if the code contains an error or not. If no error is found, then the compiler moves to the next step. Or if the compiler found errors, then it will immediately tell the developer that an error is found in the given line, so that the developer can correct them. After correcting the error when you again run the code the compiler again checks for the errors, if no error found then it will move to the next step or if an error is found then the compiler gives a message to the developer. In C# there are two types of errors:

  • Compiler error: Errors that occur when the developer violates the rules of writing syntax are known as Compile-Time errors. This compiler error indicates something that must be fixed before the code can be compiled. All these errors are generally detected by the compiler and thus are known as compile-time errors. For instance, missing semicolon, missing parenthesis, etc_._
  • Runtime error: Errors that occur during program execution (run-time) after successful compilation is called run-time errors. One of the most common run-time errors is division by zero also known as Division error. These types of errors are hard to find as the compiler doesn’t point to the line at which the error occurs. ➢ Step 4: Languages such as Java or C# are not directly converted or compiled into machine level language or machine instructions. These languages need to be converted to an intermediate code first, which is a partially half compiled code. For C#, the source code is converted to an intermediate code which is known as Common Intermediate Language (CIL) or Intermediate Language Code (ILC or IL code). This CIL or IL Code can run on any operating system because C# is a Platform Independent Language. ➢ Step 5: After converting the C# source code to Common Intermediate Language (CIL) or Intermediate Language Code (ILC or IL code, the intermediate code needs to be converted to machine understandable code. C# uses the .NET Framework and as part of this .NET Framework, the Virtual Machine component manages the execution of programs written in any language that uses the. NET Framework. This virtual machine component is known as Common Language Runtime (CLR) which translates the CIL or IL code to native code or machine understandable code or machine instructions. This process is called the JustIn-Time (JIT) Compilation or Dynamic Compilation which is the way of compiling code during the execution of a program at run time only.

Step 6: Once the C# programs are compiled, they’re physically packaged into Assemblies. An assembly is a file that contains one or more namespaces and classes. As the number of classes and namespaces in program grow, it is physically separated by related namespaces into separate assemblies. Assemblies typically have the file extension .exe or .dll depending on whether they implement applications or libraries respectively, where EXE stands for Executable and DLL stands for Dynamic Link Library. An EXE (Executable) file represents a program that can be executed, and a DLL (Dynamic Link Library) file includes code (Ex: Library) that can be reused across different programs. ➢ Step 7: Now, the C# compiler returns the output of the given C# code (argha_C14, 2021) Figure 10 : Compilation process of C# code Chapter 4 – Evaluate how the problem is solved from the designed algorithm to the execution by a specific programming language. (D)

1. Test case

  • Creator: NOname
  • Create date: 11/08/

Verify that the message " The equation has a multitude of solution " is displayed when the user enters a = 0 and b = 0. Calculate the results of the first- order equation (ax

  • b = 0) by x = - b / a
  • a = 0
  • b = 0 The equation has a multitude of solution The equation has a multitude of solution Pass

Verify that the program will give an error message and asks to re-enter when the user enters a letter a and b > 0. Calculate the results of the first-order equation (ax + b = 0) by x = - b / a

  • a = a
  • b = 8 The program has an error message and asks to re-enter Back to part code and error message Fail

Verify that the program will have an error message and asks to re-enter when the user enters a > 0 and b is the letter. Calculate the results of the first-order equation (ax + b = 0) by x = - b / a

  • a = 4
  • b = b

The program has an error message and asks to re-enter Back to part code and error message Fail

Verify that the program will have an error message and asks to re-enter when the user enters a = 0 and b is the letter. Calculate the results of the first-order equation (ax + b = 0) by x = - b / a

  • a = 0
  • b = b The program has an error message and asks to re-enter Back to part code and error message Fail

Verify that the results of the first order equation will be displayed correctly when the user enters a ≠ 0 and b = 0. Calculate the results of the first-order equation (ax + b = 0) by x = - b / a

  • a = 4
  • b = 0 x = 0^ x = 0 Pass

Verify that the program will have an error message and asks to re-enter when the user enters a and b are the letter. Calculate the results of the first-order equation (ax + b = 0) by x = - b / a

  • a = a
  • b = b The program has an error message and asks to re-enter Back to part code and error message FailTest case 1:Test case 2 :

Test case 5 :Test case 6 :Test case 7 :

Test case 8 :Test case 9 :