14
Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Embed Size (px)

Citation preview

Page 1: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Program #2

Cell Phone Usage

….Let’s start with understanding the problem!

Page 2: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Understanding the Problem

What is the input?Where does the input come from?What is the output?Where should the output go?Any calculations we need to worry

about?Who is the user?

Page 3: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Writing the Algorithm

Step #1: Welcome the UserDecide what you want to say, plan it out

here in the algorithmThink about who your user is…to make sure

the tone/words used are appropriateBe creative

Page 4: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Algorithm

Step #2: Get the Regular monthly charges from the userPrompt the user for the monthly access

chargesRead in the monthly access charges

What kind of variable do you think we will need?Echo the monthly access charges

Page 5: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Algorithm

Step #3: Get the Voice Charges from the user Prompt the user for the number of minutes allowed

(allowance), number of minutes currently used, and cost of minutes over the allowance. Spend some time planning what this prompt looks like. You could do 3 separate prompts if you’d like….

Read in the allowance, used minutes, and cost of overages

Echo the allowance, used minutes and cost of overages. Plan out how you want this echo to look like!

Page 6: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Alternate Step #3

Get the Voice Usage ChargesPrompt for the # minutes allowed Read in the allowance and echo itPrompt for the # minutes usedRead in the minutes used and echo itPrompt for the cost overages for too many

minutes usedRead in the cost and echo it

Page 7: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Step #4

Get the Data Usage chargesPrompt for the Text messaging allowance (#

of messages allowed before charged), number of messages already sent, and the rate per minute over the allowance

Read in the allowance, number of messages, and rate (think about what data types you will need)

Echo the allowance, number of messages or rate

Page 8: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Alternate Step #4

Step #4: Get the Data Usage Charges Prompt for the # text messages allowed Read in the # text messages allowed Echo the # text messages allowed Prompt for the # text messages sent Read in the # text messages sent Echo the # text messages sent Prompt for the cost of texting Red in the cost of texting Echo the cost

Page 9: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Step #5

Step #5: Calculate the total charges so far…Calculate Voice Charges

For voice, subtract the allowance from the number of minutes used…

If the result is greater than zero, the result needs to be multiplied by the cost

Otherwise, there are no additional charges

Page 10: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

More Step #5

Calculate Data ChargesSubtract the allowance (# messages

allowed) from the # of messages used If the result is greater than zero

Then the result should be multiplied by the cost of texting

Otherwise, there are no additional charges

Page 11: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Last part of Step #5

Now calculate the grand totalAdd together the monthly access charges,

the voice usage charges, and the data usage charges

(Think about what kind of variable you are going to need for this! Where should your answer be saved….?)

Page 12: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Steps #6 and #7

Display the results to the userPlan out what you want to say as part of

your algorithmTime to sign off! Send a termination

message thanking the userAgain, think about who your user is and

make an appropriate message!

Page 13: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Deck Check it now…

Now, go through the algorithmIs it in order?Does it make sense?Do you understand each sentenceIs it precise enough that you can now

create a C++ program from this?Let’s try in class on a few of the steps!

Page 14: Program #2 Cell Phone Usage ….Let’s start with understanding the problem!

Create a Test Plan

But, we are not yet done with the planning stage

It is now time to create a test planCreate a list of what you think the user

will type in, and what the answers should be when you run your program!