assignment 1 C sharp 1618, Assignments of C Sharp Programming

very clear pass point and many thing else include in this assignment

Typology: Assignments

2021/2022

Uploaded on 04/24/2022

unknown user
unknown user 🇻🇳

4.7

(21)

16 documents

1 / 28

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
DINH NGUYEN GIA KHANH
Student ID
GCH210153
Class
GCH1003
Assessor name
DO HONG QUAN
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
pf18
pf19
pf1a
pf1b
pf1c

Partial preview of the text

Download assignment 1 C sharp 1618 and more Assignments C Sharp 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 DINH NGUYEN GIA KHANH Student ID GCH Class GCH1003 Assessor name DO HONG QUAN 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:

1.1 Introduction:

While I was working on this assignment, I applied for trainee employment with a software development organization. As part of my interview preparation, I intend to demonstrate the problem-solving and core programming skills that I have gained while attending the 1618-Programming course at my university. (pic reference: https://auth0.com/blog/xunit-to-test-csharp-code/ ) 1.2 Define the problem: For this work, I'm going to create a basic menu-based application with five major functionalities to organize book in a library. When a user completes a choice, he or she will return to the menu to pick another option or depart. Users

can add books, search for books by the id of the book, borrow the book by its id, and return the book still by its id.

2. Problem Analysis and Solution Design: 2.1 analyze the problem Algorithm: - Define: An algorithm is a set of well-defined instructions used to solve a specific, well-defined computational problem in computer programming. It accepts a collection of inputs and outputs the desired result. (pic reference: https://www.researchgate.net/figure/The-Algorithm-of-Life-Cycle-Stages-of- the-Online-Community-The-algorithm-of-life-cycle_fig1_330986238 ) How an algorithm aids in issue solving (particularly in computing): - Firstly, algorithms are important since they not only help us solve our difficulties and many other potential concerns, but they also help us use resources efficiently. - So the effect of an algorithm can be described as developing more efficient code or resolving difficult problems. Make good use of your resources. Write programs more quickly. There are seven steps in the development of a program:

software components, such as troubleshooting, databases, and server environments.

5. Compiling and running the program:

  • This step is the process of translating source code into binary machine code so that it can be understood and used by a computer. 6. Testing and debugging:
  • In this phase, you must complete two tasks. The first step is testing, which is the act of looking for software problems in a system. This strategy must identify weaknesses and specify what will happen if they occur. It will report to the developer for debugging after this time period. Error detection is required during testing. The second step is to debug. Once the test results are received, debugging will begin in order to discover the problem and correct its software. Debugging is the process of determining and correcting the source of a problem. 7. The last step is Maintenance:
  • The process of modifying software or a program after it has been deployed in order to achieve any of the following results: Issues have been fixed; performance has been upgraded; a function has been added; and sections that are no longer in use have been removed. Use-case diagram of the requirements:

Flowchart requires in-depth discussion of how it works: 1.Menu Flowchart:

  • This flowchart provides users with an overview of how the application operates.
  • To start the program, the user will need to enter a password. If the user enters the wrong one, the program will print out an invalid password. After entering the correct password, the user can access the program's menu, which has five options: add book to library, search for book by their id, borrow book by the book id, and borrow book by the book id. The final option is to return the book to the library with their ID. If users enter special characters from the keyboard or words beside the required integers 1 to 5, the system will ask the user to re-enter until the input is valid.

3. Main option 3 borrow book from the library - The third option is to borrow a book from the library. Like book ID, I also use a list.count +1 for every single user. The program will ask the user for the ID of the book that they want to borrow, and then the program will ask the user for the number of books that they want to borrow. After that, the program will also ask for the user's address if the book ID and the amount of the book exist. The program will print out the name, day, and time, the address of the user, and the ID of the book. The last is the amount of the book. Details of the problem: - still missing some validation. - and the book ID is still automatic 2.2 Design the solutions: Components, data, structures needed to implement the given solution: - Language: C# (C sharp), a widely-known programming language that is mostly utilized in the development of desktop programs, online applications and web services, as well as games in Unity. - tools: Microsoft Visual Studio, Microsoft's integrated development environment (IDE). This is an excellent tool for novices, since it is used to create computer programs, online apps, services, and so on.

Components in my code :

  • Data: option, book ID, book count, book price, user id, borrow book id, borrow date, borrow count.
  • String: book name, book author, user name, user address, password.
  • Structures: if…else, list.count+1, do….while, foreach. Procedural Programming Paradigm:
  • Procedural Programming may be the first programming paradigm learned by a new developer. Fundamentally, procedural code is the code that tells a device how to do a task in logical stages. This paradigm employs a top- down linear approach and regards data and methods as distinct entities. Procedural Programming separates the program into procedures, which are sometimes known as routines or functions and simply comprise a set of actions to be carried out, based on the notion of a procedure call. (Bhatia, 2021) some key characteristics:
  • Modularity: Modularity refers to the use or use of modules, often known as pieces or portions. It involves breaking down a complex problem into smaller parts in order to tackle it quickly. (farzeen, n.d)
  • Predefined functions: In a program, a function is a procedure that may be invoked by its name. Built-in functions are another name for predefined functions. They are a collection of subroutines that perform specialized functions. These functions are often included in high-level programming languages such as Python and C++, but they can also be imported into the programming language via registries or programming libraries. (farzeen, n.d)
  • Local variable: Variables are storage locations in computer languages that have unique names. They can be assigned values by users. They are used to refer to a program's stored value. Variables are classified into two types: local variables and lexical variables. (farzeen, n.d)
  • Global Variable: Global variables can be used everywhere in the program and in any function. Any function in the program can modify their values. The set of global variables that may be used everywhere in the program is referred to as the global environment. Global variables are mostly used to transfer data across areas of code that do not have a caller/callee relationship, such as signal handlers and concurrent threads. (farzeen, n.d)

language (MSIL). It is kept in the form of an executable file (exe). The.NET framework invokes the compiler just in time to convert the MSIL code to machine code and run the program. Because this intermediate language is so close to machine language, translation is speedy. (pic reference: https://codeasy.net/lesson/c_sharp_compilation_process ) Screenshots of projects: My mac doesn't support file exe or app. So I don't have a shortcut to run the program directly. but here the running of a menu-based program:

Task 4: Evaluate how the problem solved from the designed algorithm to the execution program written by a specific programming language: 4.1 how the program work : snapshot of a running program

  • The program will first ask the users for their password.
  • After that, the main menu will pop up with a list of 5 options.
  • User can choose any of the listed options also user can choose to exit the program. figure: password and menu

Option 2 : Looking for a book by the ID of the book

  • Like option 1, users have to re-enter the second option to search for any book that is already input in the library.
  • The program will print out all the information about the book that the user wants to search for. figure: searching for book Option 3: borrow book
  • Users have to input their name, their address, the book's ID, and the number of books that they want to borrow. After that, the program will print out the date and time of the day that the user borrowed. The program will also print out "borrow success" if the user inputs the right value.

figure: borrow book option 4 : return book to the library

  • just like option 3. The user only has to input the ID of the book and the program will print out the book that has been returned. If a user inputs wrong values, the program will force the user to re-enter the values until they are right. figure: return book to the library option 5: Closing program
  • The program will print out. Thank you and see you later. figure: closing program

figure: search book by book id

  • This function does the displaying part. It will print on the screen the information about the book, but if the user inputs the wrong ID, the program will print out "book id not found." 3. borrow book from the library function: figure: borrow book function

figure: function with more condition

  • This function assists the user in borrowing books depending on the books already entered into the application.
  • As usual, I still use the list.count +1 for user id, but the user must enter their name.
  • The user then enters the book id they want to borrow (the book id is already present in the booklist.exist).
  • Then the user enters the number of books they want to borrow (the book amount is already present in the booklist. exist too)
  • I also use the int.tryparse structure for the condition that the user can only input positive numbers.
  • Finally, If the book id does not exist, the program will print out the book id not found and borrow fail. 4. Return book to the library function.
  • Basically, this function's working depends on the foreach ,if...else structure, and the user can only input positive numbers. After the user inputs the right values, the program will print out the book has been returned.