C++ for cartography and geodesy students: How Eratosthenes calculated the radius of the Earth
A computer training program to be used as training content in lectures, seminars, and homework has been developed. The program computes the radius of the Earth by the method of the ancient Greek scientist Eratosthenes
At the Moscow University of Geodesy and Cartography the training course “C++ for cartographers and surveyors” is used to educate students. The C++ programming course focuses on the use of cartographic tasks and geodetic exercises to illustrate various programming language constructions. A computer training program to be used as training content in lectures, seminars, and homework has been developed. The program computes the radius of the Earth by the method of the ancient Greek scientist Eratosthenes. A detailed reference source that explains the purpose of the program instructions used has been developed.
The C++ programming course for undergraduate students developed at the Moscow State University of Geodesy and Cartography (MIIGAiK) is geared towards the needs of the surveying and cartographic industry. This is the request of today to create programming courses suitable for particular higher education institutions taking into account their scientific specialization. The course lectures contain a large number of C++ programs, with almost every new concept of the programming language illustrated through a training program. A dialog of the user running the program is given, as well as the output of the program to the screen. Thus, in the lecture, practical, and homework the students are taught with the use of ready-made programs. All of these computer programs have geodetic content. Another innovation used in this course is a verbal analysis of the code that means the students perform analysis of the programs in speech with the help of an interactive electronic board.
The program design has been developed for quite a long time and now several design methods for the computer industry are used, for example, object-oriented design (OOD), domain-driven design (DDD). The ultimate goal of any design process is a software product created with minimum costs and on time. However, the universal methodology of educational programming for teaching students has not yet been developed. It is likely the educational designing and programming should be based on domaindriven principles of teaching (DDT). This teaching of programming should be based on thematic training computer programs and specialized courses, related to the particular engineering specializations. For example, it is necessary to use tasks and programs from general geodesy for teaching surveyors and cartographers. On the other hand, it is necessary to use the tasks and programs from physics that are suitable for physicists and so on.
The existence of specific literature, which could support the training process, is an important indicator of the formation of academic discipline. It should be noted that now providing such literature is quite satisfactory, seeing that there are many textbooks on programming in C++. Some of them are presented in the list of references [1-4]. Nevertheless, there are no C++ programming textbooks focused on training specialized engineers such as cartographers and surveyors.
Application of training computer programs with geodetic content in the educational process
There are quite a lot of options for using ready-made programs in practical. First, a ready-made and debugged code could be used directly. For example, students can be asked to run a program on a PC with a programming environment installed. At the initial stages of the programming training course, when the student masters the features of the code development environment and writes a code after a ready-made sample program. This way of using ready-made programs is a very effective way of teaching programming.
Typing a code cannot be considered an exercise of little use, and here an analogy of making a conspectus of a topic under study after a textbook is read. When typing the code, students memorize the spelling of keywords, learn to use formats of C++ programming language constructions, and a lot of other useful information occur. The student gains experience of work with the development environment, which is a prerequisite for writing and running programs. At the same time, the student accumulates knowledge in creating programs, code editing, and bug finding. Special schemes have been developed to make fault finding more effective. Typing the code and working with it, the student gets acquainted with them. In practice, it is possible to offer students to work with ready-made programs that contain artificial errors already introduced in them. Completing such training tasks, students are taught to detect and correct simple syntax errors deliberately placed in the program code.
In later stages of training, working with ready-to-use programs is also very useful. Once the program is launched, the task of a student is to examine the performance of the program. The expected result is to be compared with the observed result obtained via running the program on PC. The student independently analyzes the code, studies the data and in this respect formats that must be entered into the program, as well as their influence on the program output. A PC is a good assistant to a student in this work.
Through interaction with the program, a student gets a deeper understanding of the purpose of the program and forms a detailed view of its implementation. After self-study of the code, the student, having prepared a spoken reply explains to the audience how the program which is being displayed on an interactive electronic board works. The teacher’s computer controls the electronic board.
A spoken analysis of the code which could be observed on the electronic board is a very important element of training since the entire group in the computer class is involved in this process. As a result of such collaborative work with the code, effective solutions are found, and the correct approach to the analysis of the code is formed. This state of the student group contributes to a favorable educational environment in which the most active and successful students teach lagging students. Learning takes place in a friendly atmosphere and consequently has a high rate of benefit. The role of the teacher in this learning environment is to monitor spoken replies and explain the most complex parts of the program code. Such an educational environment simulates the usual communication between students, devoid of external adverse factors, and contributes to the development of an effective learning process in the student group. The educational process acquires the features of the game when a group of “excellent students” and a group of “C grade students” are naturally formed. The fallen behind students are, therefore, not selfcontained. Actively observing the spoken analysis of the program, they absorb the elements of reading the program code. By regularly listening to explanations of the program parts, the C-students are encouraged to improve their knowledge of the programming language. As a result, the spoken analysis of the code becomes a stage performance where the whole group takes part. This is the most interesting part of practical. The reading and interpretation of computer programs largely replace the input and running of those programs on the computer.
The program, as a work of intellectual creativity, has its own inner beauty familiar to programmers. A proper and effective program is usually also aesthetically attractive. To develop a sense of aesthetic perception of a code, it is necessary to acquaint students with samples of “beautiful” programs. Computer programs used in this course are enriched code, which is a specific style of coding. Providing detailed comments, usage of meaningful identifiers, consistent indentation, and vertical alignment of curly brackets are the main characteristics of this coding concept. Vertical formatting is also used to improve code readability, highlighting the basic units of a program, such as control statements and functions. This approach makes it much easier for students to learn a software code that is comprehensive and well recorded.
The first student programs are usually very far from the perfect ones. Nevertheless, students receive tasks to develop their own curriculum models. But it is highly desirable to acquaint students with programs written by professional programmers who possess the knowledge in the specific field of activity in which students are trained.
Let us discuss the advantages of using ready-made programs as homework. Homework, unlike practical, is focused on students working on the program during longer periods. This allows for more complex programs to be developed at home so that students can deliberate over a problem. There are several options for working with homework readymade code. The first way is to modify the program to increase its functionality. If the program works with input data from the keyboard, it is possible to modify the code so that it is possible to import data from a file into the program. If there is a program that handles user input from the keyboard, its protection could be strengthened by making it more resistant to entering false data.
Another way of working with the code of the ready-to-use program is to detect artificial errors intentionally made in the code. Search and detection of errors in the code takes the lion’s share of program development time. It is advisable to upgrade this skill to students along with the study of algorithms and methods of coding in the C++ programming language. As is well known, the errors a programmer encounters are of three main types: syntax, logic, and runtime errors. The last category of bugs is considered the most complex and difficult to detect. Nevertheless, syntax bugs and even some types of logical bugs that may be included in the program code are intended to encourage students to detect and eliminate them. The task of the learner, in this case, is to detect bugs, debug and run the program. Such assignments have one important advantage in terms of checking student’s performance. The debugged program works, and it is easy to find it out as soon as the teacher looks at the PC screen.
A working computer program can be used as an illustration of software designs when lecturing. Visualization of the program code via an interactive board allows students to observe the program work and make sure of the purpose and use of new software constructions. Demonstration of a running program is the best way to familiarize students with the specifics of the code. An entire program can be displayed on the whiteboard since it usually takes no more than 70 lines of code. Analyzing the entire program, not a piece of its curricula makes it easier to understand the program code. As a result, a student gets acquainted with the syntax of programming language constructs and practices to include any particular construct in the program.
The active interaction of the lecturer with the program is a computer experiment. For example, projecting a program performance on the whiteboard, a lecturer can change the value of a constant or a loop counter. Then the program is compiled once again, run, and the results of the program are immediately shown. Experiments on the code are didactic and allow introducing elements of a game into the lecture. Lectures become less formal if the lecturer communicates with the students asking, for example, “What happens if you change the type of this variable?” or “What happens if you change places of those two functions in the program code?” There is a dialogue between the lecturer and the audience. Course content obtained at such lectures is easy to memorize. Students actively discuss it after lectures. For an experienced lecturer, it is not difficult to find intriguing tasks for demo computer programs, search for a solution of which will be of interest to the audience.
Problems of remote examination of C++ programming at the present stage
The CORONAVIRUS / COVID-19 pandemic has significantly affected higher education, which includes the training process at the Moscow University of Geodesy and Cartography. As a response to the pandemic, distance learning has rapidly been introduced into the training of students. In the educational process, three main components of distance learning are implemented. They are distance lectures, distance practicals, and distance examination or assessments of the students’ knowledge. When it comes to teaching C++ programming, distance lectures and practicals were less affected than the distance exam. Indeed, it is currently difficult to determine which way of teaching is more effective in classrooms or online. The same is true in the case of practical. Obviously, there is no need to complete the programming task having the entire group of students in the classroom. It’s quite possible to work on it at home.
The assessment of the knowledge, conducting examinations and tests remains a complicated process. This is probably the most problematic part of the learning process in terms of a pandemic. Therefore, let us consider the option of a distance exam that is often encountered in practice. This example illustrates the difficulties and disadvantages of the conventional exam carried out remotely.
At a pre-arranged time, for example, at 9:00, a teacher sends a letter with the number of the exam ticket to a student. The student applies to the website of the department, which contains the exam tickets, and downloads the ticket to his computer. The student has approximately an hour to write down all the answers on the paper sheet. At the final stage of the exam, the student photographs the answers using a smartphone and, having combined the images in a PDF file, sends them to the teacher. The teacher reads the written answers and checks the exercise. To make it easier to work with files, students are asked to mention the full name, group number, and ticket number in the title of the file.
There are serious drawbacks in the above-described technology for remote examination. The following are the main ones. At the examination, students have free access to the Internet, so they can easily find answers online. It is quite difficult for the examiner to monitor the process of preparing written answers by students. It could be even more challenging in terms of the groups consisted of more than 20 students. Only a small number of students can be observed via videos on the PC screen in a relatively large format. Videos of students on the PC screen are small and therefore have a small resolution. Remote control over the examination leaves much to be desired. The lighting in a student’s room has a significant impact on the quality of the video image. Insufficient lighting degrades image quality, as does too much bright light. Of course, it is worth notifying the students in advance about the specifics of workplace lighting. However, in large study groups, it would not be easy to monitor the implementation of such agreements. The teacher should not interfere with the preparation of the written answers to the exam questions in order to allow the students to focus on the exam.
The technology of the exam described above is not efficient because many requirements need to be met. This way to combine two technologies the conventional decades-proven technology of using exam tickets and modern paperless information technology is not good.
Trying to combine those technologies for the examination appears to cause inconvenience. The way to improve this situation is to give up the old technique and switch to new information technology. Obviously, the paper ticket exam makes it possible for a student to take time and reflect upon a written answer. Since there is no way to conduct a remote exam without the Internet, it is necessary to stop writing answers to the paper. Online testing should be used instead of examination tickets. Computer testing is well known, widely used, and should be an alternative to exam tickets. The peculiarity of online testing is its efficiency, and the testing program sets an intense rhythm for the exam, so there is no time to look for answers on the Internet. To maintain a fast pace of the exam, each question is accompanied by a set of answers, and a student must choose the correct one. Lack of time for searching for the answers on the Internet is the main advantage of online examination tests.
What are the requirements for online testing and software for conducting a remote examination? The number of answers to any question should be not more than 5 answers. Often only 4 answer options are enough. Each question is displayed on the computer screen only for a certain, predetermined time. The student should be aware of how long the question would remain on screen. If the answer is not chosen, the question disappears from the screen and another question is displayed.
The fast-paced exam process requires a lot of energy and concentration, so the exam time should probably be reduced to 30 – 45 minutes. It is possible to divide testing into several stages, carried out separately from each other in time. The testing program should be able to automatically evaluate the results of work, calculate the band and the performance time, as well as the value of the selected answers. The task of a teacher is to develop an exam questionnaire taking into account the contents of the training course. The program will evaluate the results of the testing in automatic mode.
What additional functionality should a program for conducting distance exams have? It is advisable that the interface of the testing program occupies the entire PC screen. Furthermore, if the program for testing would be supplied with an eyetracking system then it becomes impossible to look for the answers using another device, for example, a smartphone or tablet.
We now turn to the analysis of the developed program. The following is a computer program designed to be studied at the beginning of the training course. The program demonstrates the use of variable declaration statements and arithmetic operators.
Articulation of the problem
Let us dwell on the geodetic formulation of the problem. It is believed that the ancient Greek scientist Eratosthenes, who lived in the city of Alexandria around 240 BC, was the first to calculate the radius of the Earth. Here is the simplified version of Eratosthenes’ method described by Cleomedes (Greek astronomer) to popularize the discovery. Eratosthenes knew that in the city of Syena on the summer solstice, objects do not cast a shadow. Syena is located south of Alexandria at a distance of 5,000 stadia (a unit of length in the ancient world), and these two cities are located on the same meridian. The scientist measured the angle between the Sun at Zenith in Alexandria on that day, and the result obtained was approximately 7.2°. On the basis of these data and using the below-given proportion Eratosthenes calculated the length of the arc of the Earth’s circumference:
As a result, the Earth’s radius is 39789 stadia. At present, it is not known what kind of stadia the scientist used. There was an Egyptian stadium (equal according to some sources, 157.5 m, according to others – 172.5 m), a Greek stadium is of 178 m. If a stadium is equal to 157.5 m, it turns out that the radius of the Earth is 6267 km. For modern data, the average Earth radius is 6371 km. In Fig. 1 a diagram illustrating the Eratosthenes’ method for determining the Earth’s radius according to Cleomedes is presented. This is only the scheme and the sizes of individual portions for clarity and understanding of the solution are distorted.
Discussion of the results
The program developed is intended to illustrate the training content of the second lecture of the course “C++ for cartographers and surveyors” . In this lecture, students are introduced to programming concepts such as constants, variables, and types of variables, learn to compose programs using arithmetic operators. The lecture describes how to write comments in the style of C++ and C. The features of input and output of data to the screen using setprecision (0) are considered. Examples from geodesy and cartography show how to use enumerators. Making students familiar with overflow errors usually takes place at the initial stage of the programming course. Learning to work with variable types and constants is a milestone in mastering the basics of programming. Let us take a closer look at the code of the program.
Each of the programs used in the “C++ for Cartographers and Surveyors” course has an explanatory reference intended for students to learn what a computer program does and how it works. The following is an explanatory reference for the program under study.
In lines 07 – 09 variables are initialized: the variable angle is 7°12′, distance from Alexandria to Syena would be distanceFromAlexandriaToSyene equals 5000 stadia, and variable EarthCircumference is unknown. The EarthCircumference is computed by formula 1 put into line 11. Line 13 computes the Earth’s radius using formula 2. Next, in line 15, the radius of the Earth is displayed on the screen, and the output of the radius value is carried out as an integer without a fractional part. In line 18, one stadium is a variable oneStadium, and it is initialized with a value of 157.5 m. Then in line 18, the value of the radius of the Earth in stadia is converted to the value in kilometers, and the result is displayed. In line 22, two variables of absolute and relative errors are declared. Their values are computed in lines 23 and 24. The results are displayed on the screen. This is where the program stops.
Let us compile and run the program, so the following output is got: Eratosthenes’ problem Earth radius in stadia: 39789 Earth radius in km: 6267 Absolute error, km: 104 Relative error, %: 2 Let us make a final remark. As can be seen from the result, the error in the determination of the radius of the Earth by the Eratosthenes method is insignificant even from the point of view of modern times. Of course, if one stadium is equal to 178 m, the value of the error will increase. Calculations show that the relative error will be 11% respectively.
The training course “C++ for cartographers and surveyors” is used to educate students at the Moscow University of Geodesy and Cartography. The issues of the development and use of a training course under the conditions of the teaching of students in two academic subjects of general geodesy and programming are considered. A computer training program to be used as training content in lectures, seminars, and homework has been developed. The program computes the radius of the Earth by the method of the ancient Greek scientist Eratosthenes. The program can be used as training material in a programming course to illustrate instructions of initialization and declaration of variables, arithmetic operators. An example of reference information for self-study, which describes in detail the program code and explains the purpose of the instructions used, is presented.
Deitel H., Deitel P. (2006) C++ How to program. Prentice Hall, New Jersey, USA.
Podbelskiy V.V. (2003) C++ language. Finance and Statistics. Moscow, Russia.
Siddhartha Rao (2012) SAMS Teach Yourself C++ in one hour a day. SAMS, USA.
Stroustrup B. (1997). The C++ Programming Language. Addison- Wesley, Reading, USA.
Zablotskii V.R. (2019) Training computer programs for the geodesy and cartography students: determining the coordinates of points using the geodetic intersection and resection. Proceedings of the 19th Geoconference, SGEM-2019, Bulgaria. https://doi. org/10.5593/sgem2019/2.2/S09.049.