Thursday 1/31 Week 3

Chapter 3

Student Notes

 

Objectives

Case Studies

Assignment Statements

Arithmetic Operators

Formatting Numbers

Order of Operations

Common Errors

 

 

1. Case Studies (handout)

·        Must be turned in with every project from now on

·      Staple or heavy binder clip if too big for a staple

·        All sections should be typed

·        Signature Page: found on the web. Should always be the first page.

·        Problem Specification: The assignment page to be found on the web or handed out in class. This is given to you. Should be the second item in your Case Study.

·        Analysis (1 pt): A brief restatement of the problem in your own words. This shows the grader that you understand the problem statement.

·        Data Requirements and Formulas (2 pts): generally, there are your variables and constants. Each variable and constant must include the declaration (this can be copied from the code) and an explanation of how the variable will be used. If your program requires any special mathematical formulas, state these here.

·        Algorithm (3 pts): Your fully refined algorithm in outline form.

·        Test Plan (4 pts): a table identifying each test case, the expected output, the actual result, and the reason for testing this case.

·        Implementation (4 pts – code; 6 pts turnin): your .lsb files of any file that you wrote or edited for the project. You need not include any files or packages which you used, but did not “touch”. Also, this section includes a .turnin file of the run of your test plan. You must run each case you propose in your test plan, in order. The turnin file should be as clean as possible, but a few mistakes are OK. The grader needs to be able to follow the results. It is helpful if you label the test cases in pen on the print out. 

 

2. Assignment Statements & Mathematical operations

·        SquareYards := MetersToYards * SquareMeters;

·        Note the := for assignment

·        Operators:        +

                              -

                              *

                              /

**

·        Sum := Sum + Item;

·         

·         

·        Note that the – sign can also be used to give the opposite of a value.

·         

·         

·         

·        Parentheses are allowed in equations, just like algebra .

 

3. Order of operations

·        Some operations are always performed before others

·        (parenthetical expressions) -> ** -> * , / -> +,-

·        use parentheses to

·         

·        equations are evaluated

 

 

4. Formatting numbers

·        Integers use the Width parameter to specify the minimum number of spaces the number will use. If the number is larger, then the full number will be printed.

Ex. Ada.Integer_Text_IO.Put(Item => 345, Width => 5);

**354 (* used to show spaces)

Ada.Integer_Text_IO.Put(Item => 45890, Width => 3);

45890 (used more than the 3 spaces)

·         

·         

·         

·        Floating point values are printed in scientific notation as a default

·        To reformat, use

     Ada.Float_Text_IO.Put(Item =>12.9, Fore =>5, Aft =>4);

  ***12.9000