HWII ProgrammingII (0)
TALLINN UNIVERSITY OF TECHNOLOGY
School of Information Technologies
Department of Computer Systems
BOOK SHOP B
Homework II
Supervisor:
Lembit
Jürimägi
Tallinn
2021
Tallinn
2021
Author’s declaration of originality
I hereby certify that I am the sole author of this thesis. All the
used materials, references to the literature and the work of
others have been referred to. This thesis has not been presented
for examination anywhere else.
Author:
01.06.2022
3
Table of contents
4
Table of figures
1.Task description
My student code is xxxxx1 and my task is Book Shop B. For my
variant I need to create two text files: “books.txt”, which stores
all the information about the books, and “inventory.txt”, which
stores all the records about the quantity and location of books in
the shop. The point of the program is to read data from these
files and rearrange it according to the user's requests. The user
can choose from the menu of options what to do, and the
program doesn’t end until the user chooses to end it. The
following are subtasks of my variant thus options the user may
choose from:
-display full data
-add a new book
-change an existing book
-add inventory
-search by author
-clearance sale
5
2.Data model
The two files containing book information are connected
between each other by the book ID code. In “Books” code is a
primary key, and in “Inventory” code is a foreign key that gives
an opportunity to link the two of them together.
figure 1. Data model
6
3. Solution description
Program description
My application works with files I created and only asks the user
which command they want the program to execute and if the
subtask demands it, the user is asked to manually input some
data. I only read data through fgets() function throughout the
whole code, because I didn't want problems with intersecting
scanf() and fgets(). In the end it was just easier to read
everything the same way.
Data format
I chose to work with text files in my code.
Each string is read through fgets() and then each element of
data is assigned to a variable in sscanf(). After reading all the
data it is stored in structs.
The 1st file is “books.txt”: it stores the code, title, author,
publisher, year, cost price and selling price of the book. There
are 12 books in the shop:
figure 2. file 1 - “Books”
The 2nd file is “inventory.txt”: it stores the quantity, shelf, and
the code. There are 30 records of inventory:
7
figure 3. file 2 - “Inventory”
The flow of my program
-main function calls menu;
-menu initialises integer b and equates it to 1;
-do while loop starts;
-user is asked to choose an option;
-all subtask functions are called by menu, depending on the
user’s choice
-once the subtask is executed, the user is asked if they want to
continue;
-if user is done, b equates to 0 and the loop ends, along with the
program.
The functions I implemented
● void ReadingFileName
First, I read the names of two files and store them in char
variables.
The input has to be the name of the file with “.txt” at the end.
I call this function in main twice for both files.
8
● int ReadingBooksFile
Next Iread data from the first file and store it in my first struct
for book information, while reading each line I count the amount
of lines -> therefore the amount of books. Return value -
amount of books. Amount of books is a parameter in every
subtask function.
● int ReadingInventoryFile
This function is identical to the previous one, except the data is
read from the second file. Data is stored in the second struct for
inventory records, the return value is the amount of records.
● void Menu
Menu is the function that calls all subtasks functions, therefore
the parameters include all the parameters that every other
function has. Menu is written inside a loop that continues while
the user chooses to go back to it. The switch case based on the
user's input defines which function is to be executed. No return
value is needed here, and in all upcoming functions.
● void Displaying data
In order to display data I needed to merge the data from my two
main structs, so I created a third struct called Full_Data and
reassigned all the values from both previous structs there,
connecting them corresponding to the Primary key - book code.
The quantity in Data struct is summed up from all records
corresponding to the same code. Then I just printed out all the
fields in each Full_Data struct.
● void AddBook
If a user wants to add a book, they have to enter all the
components of the new book. The application then stores the
9
new book in both Books and Data structs and appends the
information to the “Books” file.
● void ChangeBook
Changing a book is possible by entering the title of the book you
want to alter and if that book exists in the file the program
needs an input of new components of the book. After it gets all
the new credentials, the new information is stored in Books and
Data structs. In the end I write over the Books file (intentionally
erasing all its data) and rewriting each book record from
updated structs, getting the same file with one altered book.
● void AddInventory
Similar to AddBook function, but the data given by the user is
written into the Inventory file and struct, and the new quantity
from the input is summed up with the existing quantity in the
Data struct with a corresponding code.
● void SearchByAuthor
This function is pretty straightforward: the user enters an
author, and if that author exists in the Book Shop the program
displays information on books by that author. Data struct is used
for this.
● ClearanceSale
Here a user enters a number and the program displays books for
which the quantity is less than the user’s filter.
● int main
In main I just call functions ReadingBooksFile and
10
ReadingInventoryFile and get the amounts, then I allocate my
three structs in the memory as well as allocating memory of my
structs and freeing it in the end. After I call Menu in main, Menu
becomes the primary function that controls the rest of the code.
Exceptions
In SearchByAuthor and ChangeBook user has to enter an
existing element of the files in order to change, add, and display
the rest of the data. So, if a program cant find the element in
the file, the program lets the user know and asks to repeat the
input.
figure 4. programs, reaction to wrong input in SearchByAuthor
11
figure 5. Programs reaction to wrong input in ChangeBook
12
4. Summary
After completing this Homework i learned how to make an
interactive menu and do more user-friendly programs. This also
includes calling different functions inside of each other, which
reminded me why it's better to declare functions in the
beginning of the code before main, and putting the main
function as the first function of the code. Also consolidateв
knowledge of structs in C as a form of data storage. Some things
with reading and writing into files were trickier than I expected.
13
Appendix 1 – Screenshots
figure 7. DisplayData function output
14
figure 8. AddBook function output 1
figure 9. AddBook function output 2
15
Sarnased õppematerjalid
402
pdf
CPM1A Programmable Controllers Operation Manual 1784470
• Construct a control circuit so that power supply for the I/O circuits does not
come ON before power supply for the Unit. If power supply for the I/O circuits
comes ON before power supply for the Unit, normal operation may be tempo-
rarily interrupted.
• If the operating mode is changed from RUN or MONITOR mode to PROGRAM
mode, with the IOM Hold Bit ON, the output will hold the most recent status. In
such a case, ensure that the external load does not exceed specifications. (If
operation is stopped because of an operation error (including FALS instruc-
tions), the values in the internal memory of the CPU Unit will be saved, but the
outputs will all turn OFF.)
14
docx
Trojan horse
Eriala: Informaatika
Inglise keel
Referaat
«Trojan horse »
Lektor S.Remmelg
Üliõpilane A.Parts
Rühm RDIR23
Kood 103373
Introduction
Trojan (also - troyamn, troyamnets, troyamnsky horse Troma) - a program used by an attacker to
gather information, its destruction or modification of, computer malfunction or use of its
resources in the wrong purposes.
According to the principle of distribution and of the Trojans is not a virus because it does not
spread by self-reproduction.
This Trojan is run by the user manually or automatically - the program or part of the operating
system running on a victim computer (as a module or utility). For this program file (the name,
11
pdf
Projekt
Tallinna Tehnikaülikool
Raadio- ja sidetehnika instituut
Projekt
ainetes ,,IRT0030 Andmeside"
ja
,,IRT0100 Kommunikatsioonivõrkude struktuurid ja teenused"
teemal
«VoIP teenus»
Üliõpilane: Ruslan Karpovits
Õpperühm: IATM
Matrikli nr: 050829
Õppejõud: Avo Ots
Tallinn
2008
Author's word
This project is written to show some interesting aspects of working with VoIP (Voice over
Internet Protocol) service. The project briefly describes the process of finding a solution for
based VoIP problem and its realization.
555
doc
Programmeerimiskeel
mistakenly referred to as the "IBM UNIVAC." Remington Rand eventually sold 46 machines at
more than $1 million each.
SPEED: 1,905 operations per second
INPUT/OUTPUT: magnetic tape, unityper, printer
MEMORY SIZE: 1,000 12-digit words in delay lines
MEMORY TYPE: delay lines, magnetic tape
TECHNOLOGY: serial vacuum tubes, delay lines, magnetic tape
FLOOR SPACE: 943 cubic feet
COST: F.O.B. factory $750,000 plus
Early AI programs: checkers, chess (in Britain)
Strachey wrote a checkers program for the Ferranti Mark I at Manchester (with Turing's
encouragement and utilising the latter's recently completed Programmers' Handbook for the
Ferranti computer). By the summer of 1952 this program could, Strachey reported, "play a
complete game of Draughts at a reasonable speed".
Prinz's chess program, also written for the Ferranti Mark I, first ran in November 1951. It was for
solving simple problems of the mate-in-two variety. The program would examine every possible
140
pdf
Thesis Kivimaa August 2022
..................................................... 122
Installation of the GSES .......................................................................................................... 122
Start GSES ............................................................................................................................... 122
Results for managers .............................................................................................................. 124
Program Structure .................................................................................................................. 128
Input of collected expert information to GSRM/GSES ........................................................... 129
Security Class .......................................................................................................................... 129
MeasureGroups ...............................................................................
23
pdf
Games Programming with Java and Java 3D
the chosen JVM; IBM's implementation exceeded the performance of C++ code
compiled with gcc [Ladd 2003].
A detailed comparison of difference versions of Java and other companies' virtual
machines and native code compilers can be found in [Doederlein 2002].
An area of Java that is still slow is its GUI API, Swing. GUI components are created
and controlled from Java, with little OS support: this increases their portability and
makes them more controllable from within a Java program. The downside is speed
since Java imposes an extra layer of processing above the OS. This is one reason why
some games applications still utilise the original Abstract Windowing Toolkit (AWT)
-- it is mostly just simple wrapper methods around OS calls. However, most games do
not require complex GUIs: full-screen game play with mouse and keyboard controls
are the norm, so GUI speed is less of a factor.
Another speed drain is Java's garbage collector, which is run automatically by the
40
doc
Introduction of SCM
INTRODUCTION OF
SUPPLY CHAIN MANAGEMENT (SCM)
A supply chain is a network of facilities and distribution options that
performs the functions of procurement of materials, transformation of these
materials into intermediate and finished products, and the distribution of these
finished products to customers. Supply chains exist in both service and
manufacturing organizations, although the complexity of the chain may vary
greatly from industry to industry and firm to firm.
Supply chain management is typically viewed to lie between fully
vertically integrated firms, where the entire material flow is owned by a single
firm and those where each channel member operates independently. Therefore
coordination between the various players in the chain is key in its effective
management. Cooper and Ellram [1993] compare supply chain management
to a well-balanced and well-practiced relay team. Such a team is more
competitive when each player knows how to
17
pdf
Ssubtiitrite lugemiskiirus
These statements have been decisive to the
creation of the so-called "6 second rule", which has become a best-known teaching
standard for subtitling over the years.
Mayoral (2001, 4) mentions variable reading speeds for cinema (10 frames per
foot of film--between 14 and 15 characters per second), as used by the Ameri-
can company 20th Century Fox, while the values for television and video would
be lower. The author also mentions the television subtitling software program used
by the company Screen Subtitling System Ltd, which proposes reading speed fig-
ures of 9 characters per second for adults, and half to two third equivalent ones for
children.
As far as the usage of reading speeds expressed in WPM and how adequate it
may be in different countries, Mayoral affirms:
No se dan normas de traducción audiovisual para diferentes países (las velocidades
de lectura se establecen habitualmente --p. ej. Ivarsson, 1992, y Screen Subtitling Sys-
Sissejuhatus erialaõppesse
Meedia
Kommentaarid (0)
Kõik kommentaarid