Programming Fundamentals in Java

Module [101] - Manipulating Data

This module will introduce you to the data manipulation aspects of programming languages. We will first discuss the generic concepts of data values, variables, data types in a programming language agnostic manner. Then, we will apply our recently acquired knowledge using the Raptor flowchart interpreter to build our first programs.

This tab will provide you with reading assignments from the textbooks, along with slides and videos for additional lectures, when appropriate. Please make sure that you use the forums to ask any questions you might have while reading or watching this material. It is expected that many questions will arise and the instructor will keep an eye on the forums to ensure they are answered.

  • Textbook Reading Assignments
  • The following sections of the textbook are assigned for this module.
    • Sections #1.1 to #1.4
    • Appendix B - The ASCII Character Set
    • Appendix F - Number Systems
  • Lecture - Video - Manipulating Data
  • File Link: YouTube
  • In some modules, the reading assignments will be supplemented by lectures videos. To make it easier for you to navigate this video, you will find below links to its main parts;
  • Lecture - Slides - Manipulating Data
  • File Link: 101-lecture.ppt
  • These are the slides used in the above video lecture

Some modules will feature recordings of "live session" held online during summer 2015. For this first learning module, you will find an additional lecture.

Please ignore references to deadlines or week numbers which might pop-up in these videos; these were only relevant at the time of the recording. The advice therein about how to related the study material to each of the programming skills is still very much relevant though :)

The following lecture introduces the way to think your way through a programming problem. As we do so, we also identify the various skills which, combined together, form what most refer to globally as the "programming skill". These programming skills will be how our future "wrapup sessions" videos will revisit the study material.

The overall lecture is split into smaller videos to help you jump directly into specific programming skills as you refer back to it during the semester

  • Lecture - Video - Programming Thought Process - Introduction
  • File Link: YouTube
  • Let us start by a brief introduction...
  • Lecture - Video - PTP - Tracing
  • File Link: YouTube
  • We are now ready to jump into our first programming skill: tracing code.
  • Lecture - Video - PTP - Implementing
  • File Link: YouTube
  • Next programming skill is implementing. If Tracing was akin to code literacy, then implementing is the ability to translate an algorithm expressed in plain English into code.
  • Lecture - Video - PTP - Testing
  • File Link: YouTube
  • How do you know the code you just wrote actually does what the requirements demand? You test it of course! Now, let us take a look at what this entails...
  • Lecture - Video - PTP - Debugging
  • File Link: YouTube
  • When your test fail, who you gonna call? The debugging skill of course!
  • Lecture - Video - PTP - Refactoring
  • File Link: YouTube
  • Last skill, refactoring, is the art of taking a five minutes break once your code works, and then come back with fresh eyes to improve its quality without adding or removing any of the features it currently implement from the requirements.
  • Lecture - Video - PTP - Designing
  • File Link: YouTube
  • Let us complete our overview of programming skills with the ones that relies the most on your creativity; designing from scratch.
  • Lecture - Video - Putting it all together = PTP
  • File Link: YouTube
  • Now that we have talked about each of the skills involved in programming, let us take a look at how we are going to combine them with one another to learn the programming thought process that will guide us from requirements to solutions and code.
  • Lecture - Slides - The Programming Thought Process
  • File Link: 101-PTP-v6.pptx
  • These are the slides used in the above lecture video

Module Learning Outcomes

In this module, you will develop further your programming skills as follows;

Tracing
Ability to read and trace Raptor code that assigns values to variables and process arithmetic computations on their values.
Implementing
Ability to write Raptor code performing specified computations on variables and their values.
Testing
Ability to develop tests, on paper for now, that are going to allow us to ensure a program computes the results expected by requirements.
Debugging
Ability to troubleshoot variables assignments and arithmetic computations.
Designing
Ability to design computation steps on variables and their values that lead to a specified result.

As we work with Raptor to apply the principles learned in the study material, you should keep an eye on the following resources;

  • Raptor Official Documentation
  • URL Link: http://raptor.martincarlisle.com/
  • You will find several word and power point files on the Raptor official website. They describe all available features in details, for this reason, I do not recommend you just read these front to back but instead refer to them on a "as needed" basis to look up specific things; e.g. how to generate a random number, how does the remainder operator works...

For your convenience, some of the files we will use most are available for download below as PDFs;

  • Introduction to Raptor
  • PDF Link: raptor-1.pdf
  • Introduction to Programming with Raptor by Dr. Wayne Brown. As mentioned above, only focus on the items relevant to this module.
  • Raptor Syntax Slides
  • PDF Link: raptor-2.pdf
  • These slides summarize the main syntax used by Raptor; e.g. mod and rem operators

Now let us jump into our apprenticeship exercises for this module;

  • A01 - Hello World!
  • File Link: YouTube
  • Write a program, using the Raptor flowchart interpreter, which displays on the screen the string "hello world!".
  • A02 - Assignment Statements
  • File Link: YouTube
  • Modify the previous program, 101 – A01, to insert an assignment statement. We want to be able to greet someone with a specific name instead of just greeting everybody. To this end, our new program needs to store a string representing a name and then display its contents. We want you to assign the value "Nelson" to a variable named name. Then, you will display the string "Hello to " followed by the string you just assigned to the variable name. In summary, you have to;
    • Modify the current output statement so that it displays the string "hello to " instead of "hello world!"
    • Modify it so that it doesn't go to a new line at the end of its string (use the checkbox)
    • Add another output statement which displays only the content of the variable name
  • A03 - Displaying String Expressions
  • File Link: YouTube
  • We are going to modify yet again our program and improve it along the way. So far the program is working just fine and doing what we intended it to do. We can therefore spend a little bit of time improving the way it is written. When we are done, it should still behave the same way. If it doesn’t, well, our “improvements” might have been more in the line of bugs. We want to replace our two output statements with a single one. To do so, we need to use the Output Expression option instead of Output Text. Modify the flowchart of exercise A02 so that you output the whole expression in one output statement.
  • A04 - Input Statements
  • File Link: YouTube
  • Our program is still working. Good. Now let’s work in a small new feature. After we are done, we’ll make sure it still works. Greeting everyone in the world is good. Being able to greet a specific person by modifyuing the program so that we assign his or her name to our variable name is ok... but not great. Who wants to have to modify a program before to run it every time the program needs new data to work on? We now want to read from the user a string representing a name rather than assigning it to the variable name ourselves. Use an input statement instead of the assignment one to read a value for name from the user.
  • B01 - Converting Distances
  • Write a program which will ask the user to input an integer number corresponding to a distance expressed in Inches. You will then display on the screen the conversion of these inches into;
    • centimeters (1 inch = 2.5 cm)
    • meters (1 m = 100 cm)
    • kilometers (1km = 1000m)
    • feet (1 foot = 0.305 meter)
    • miles (1 mile = 1.609 km)
  • B02 - Converting Temperatures
  • Write a program which will ask the user to input a floating point number corresponding to a temperature. We will assume the temperature was in Celsius degrees and display its equivalent in Fahrenheit degrees after computing it using the following formula
    Fahrenheit = ( 9.0 / 5.0 ) * Celsius + 32
    	  
    Now, write another version which assumes the data was in Fahrenheit degrees and needs to compute its Celsius degrees equivalent using the following formula;
    Celsius = ( 5.0 / 9.0 ) * (Fahrenheit - 32)
    	  
  • B03 - Converting Durations
  • Write a program which will ask the user to input an integer number corresponding to a duration expressed in minutes. You will then display on the screen the conversion of this duration in the hours:minutes format. Example: If the input is 99 minutes, the output will then be 1:39. Read up in the RAPTOR documentation, available from the RAPTOR website, about the modulus / modulo operator which allows you to take two integers and obtain the remainder of their integer division. If you have troubles finding the information on the official website, here is a local copy of the relevant PDF file, you will find information about the rem and mod operators on page 7.
  • B04 - Converting Weighs
  • Write a program which will prompt the user to input a floating point number representing a weight. Our first version will assume the weight was expressed in pounds and will display its equivalent in kilograms, using the following formula;
    	    1 pound = 0.454 kilograms
    	  
    Our second version will use the same formula and assume that the user provided us a weight value expressed in kilograms which we need to display in pounds equivalent.