1 / 10

Lab Session-2 CSIT 121 Spring 2005

Lab Session-2 CSIT 121 Spring 2005. Debugging Tips NiMo’s Varying Rates Lab-2 Exercise. 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.

borville
Télécharger la présentation

Lab Session-2 CSIT 121 Spring 2005

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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

  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

  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

  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)

  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.

  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

  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)

  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.

  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

More Related