YouSub
Untitled

en English

Untitled English subtitles

0 downloads · 64 lines · added Dec 14, 2015

Report a problem
What's wrong?
Advertisement

English transcript

First, I'm going to change the app so when you hit the Order button,
it's going to show Amount Due $10 or whatever the price is.
Since there's going to be a lot of combinations where I'm going to need
the price, I'm just going to create an integer variable to hold the price.
Notice that the int is lowercase i because it's a primitive data type.
Now I can just refer to the price variable whenever I want
the price number.
Now, I need to change the string so it says Amount Due.
So, I'm going to write "Amount Due ", add a space,
and then concatenate that with the price variable.
Oh, and I forgot the dollar sign as well.
The dollar sign should be part of this string literal, and
I want it to be after a space, so I'll put it right here.
Now I'm going to run it.
If I change quantity to three and
then hit the Order button, then it correctly shows Amount Due $15.
First one done, that wasn't too bad.
Next, we want it to say that would be $10, please.
I'm going to change this text to start with That would be, and then
I want a dollar sign, the price, and then I want some more text after that.
I should say " please" and a period.
I add a space here because I want a space after the price.
Let's check to see what that looks like.
On the device, if I change quantity to three,
hit the Order button, it says That would be $15 please.
Now the second one's done.
We're on a roll.
The third one says, You owe 10 bucks, dude!
I'm going to change the start of this string to be You owe, and
then I'm going to remove the dollar sign because we just need the price,
and then we're going to add " bucks, dude!".
That looks correct.
Let's run that.
I'm going to hit the Order button.
It says, You owe 15 bucks, dude!
The fourth one is a little tricky.
We want to say 10 dollars for 2 cups of coffee.
Pay up.
I see a need for two variables here, the price variable and
the quantity variable.
We're going to start with the price, which is ten.
And then we're going to say " dollars for ", and
then I need to put the quantity and then " cups of coffee.
And then Pay up.".
Let's run that.
If I hit the Order button, then it says 15 dollars for 3 cups of coffee.
Pay up.
That looks really good.
This was tricky because we had two variables here,
concatenated with two string literals.
Fortunately, we added spaces in the right place so
that it would look like a normal sentence.
That was the hardest one, and now we can do the last one, that says Total: $10.
I'm going to erase this whole thing here, and
say "Total: " and then the price.
Oh, but I also need the dollar sign, so
I'm going to put that inside the string literal.
Oh, and I forgot the plus sign, too.
There, now let's run the app.
I change quantity to three, hit Order, then it correctly says Total: $15.
Woo hoo!
You got through all of these different combinations of string concatenation
with variables.
Now move on to the next video for your last coding task of this lesson.

Need subtitles from another video?