Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Lab Session-2 CSIT 121 Spring 2005 Debugging Tips NiMo’s Varying Rates Lab-2 Exercise.

Similar presentations


Presentation on theme: "1 Lab Session-2 CSIT 121 Spring 2005 Debugging Tips NiMo’s Varying Rates Lab-2 Exercise."— Presentation transcript:

1

2 1 Lab Session-2 CSIT 121 Spring 2005 Debugging Tips NiMo’s Varying Rates Lab-2 Exercise

3 2 Some Aspects of Visual Studio Your project can be set in “Debug” or “Release” states ( Build->Set Active Configuration ) In “Debug” state, you can apply several debugging options. Debug is set by default You can start debugging by invoking the debugger

4 3 Debugging Tips Let us try a few simple steps Open your source file, make a mistake and try to recompile it (demo) The compiler gives an error message Click on the error message The compiler takes you to the line where the error is, press F1 to learn more

5 4 Starting the Debugger Once you have compiled the project, you can start the debugger by first inserting breakpoints A Breakpoint is where the program execution will halt Thus you can see the values of variables at that point

6 5 Using the Debugger Inserting breakpoints is very convenient way of stopping at a suspected problem location and examining the values of variables (Click the “hand” in the corner) Using “GO” causes the debugger to run the program until the next break point (Click on “Build”--> “Start Debug”-->GO)

7 6 NiMo’s varying rates Example: Niagara Mohawk wants to apply different rates to its customers. If a customer burns more than 1000 units in a month, rate B is applied else rate A is applied. Develop a program that outputs the monthly bill given a customer’s consumption. Test the program with two sample customers. One customer will have rate A (20 cents) applied and the other one will have rate B (17 cents) applied to the monthly bill.

8 7 NiMo’s varying rates You develop the data model and algorithm for this problem What is the input to your function? Answer: What is the output? Answer: What are the processing requirements? Answer (A or B)*consumption Write the algorithm on paper

9 8 NiMo’s varying rates In our example, the program can be divided into three sections: Write a code segment to get the rates Write a code segment to process the charges Write a code segment to output the charges (Input  Processing  Output)

10 9 Programming Exercise Due Feb 9 Extend the NiMo program by computing the monthly bill with the energy supply charge. Energy supply charge is different for rate A and rate B customers. For rate A customers, it is 10 percent of the energy bill. For rate B customers, it will be 8 percent of the bill. Add this charge to the bill and display the cumulative monthly bill with explanatory information.

11 10 Sample Run –How many units did you burn this month?1200 –Your Electricity Bill this month is –Energy Charges $204 –Supply Charges $16.32 –Total Charges excluding taxes $220.32 –======================================= –How many units did you burn this month?900 –Your Electricity Bill this month is –Energy Charges $180 –Supply Charges $18 –Total Charges excluding taxes $198


Download ppt "1 Lab Session-2 CSIT 121 Spring 2005 Debugging Tips NiMo’s Varying Rates Lab-2 Exercise."

Similar presentations


Ads by Google