Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Session-5 CSIT 121 Spring 2006 Part D due now String Rules Chapter 2 Topics Lab Demo Exercise Assignment.

Similar presentations


Presentation on theme: "1 Session-5 CSIT 121 Spring 2006 Part D due now String Rules Chapter 2 Topics Lab Demo Exercise Assignment."— Presentation transcript:

1

2 1 Session-5 CSIT 121 Spring 2006 Part D due now String Rules Chapter 2 Topics Lab Demo Exercise Assignment

3 2 String Rules We have used text strings in the previous lab. Let us summarize the rules for strings –You must #include –You can declare a string variable as string name; – You can assign it a value in one of three ways name = “Mike Smith”; cin>>name; //can get the first name only getline(cin,name); //can get full name

4 3 String Rules You can concatenate (join) strings as follows: –firstname=“Mike”; –lastname=“Smith”; –name=firstname+’ ‘+lastname;

5 4 Chapter 2 Topics We will cover a few chapter 2 topics before we move on to the lab demo exercise

6 5 NiMo’s varying rates 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.

7 6 NiMo’s varying rates You develop the data model 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

8 7 Top Down Design If you are given a complex problem, you are better off dividing it into sub-problems Target is to let each sub-problem deal with one aspect of the software Thus you can rapidly develop the software to solve complex problems

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 Lab Work Finish the NiMo varying rates program and test it with two sample customers. One customer will have rate A (20 cents) applied and the other one will have rate B (15 cents) applied to the monthly bill.

11 10 Lab Demo Due 2/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 5 percent of the bill. Add this charge to the bill and display the cumulative monthly bill. The program should display the bill in a nice format with customer information. Assume the name as “Mike Smith” and address as “123 Main Street Anytown NY 12345”. See a sample on the next slide:

12 11 Sample Output Name: Mike Smith Address: 123 Main St Anytown NY 12345 Bill Date: Feb 9 2006 Due By: March 15 2006 Units: 1200 ************************** Charge: $180 Energy Charges: $9 Total Payable: $189 **************************


Download ppt "1 Session-5 CSIT 121 Spring 2006 Part D due now String Rules Chapter 2 Topics Lab Demo Exercise Assignment."

Similar presentations


Ads by Google