All language subtitles for 018 Scanner - part 2_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

In part one, you learn to use scanner methods next line, which works for the user to enter a string

value and next and to watch waits for the user to enter an integer next double, which waits for the

user to enter a double value and using these scanner methods.

We ask the user a lot of questions and the user responded to each one.

So in this lesson, our application is going to respond back to the user.

All right, after the user answers every question, it would be nice to respond with a thank you for

answering all five questions.

Now, should we hard code the number five directly inside the print statement?

I don't think so.

Imagine this was a bigger application with dozens of questions or I dare say hundreds of questions.

Are you going to keep counting the questions every time you add a new one?

I'd be more comfortable having Java count the number of questions for me.

So what I'm going to do is make an entire variable counter and first it's going to store the value of

zero.

Then we can use the add one operator plus plus that we learned about and that's going to increase the

counter value by one every time we ask a question.

And so in the survey costs, we're going to make it into variable counter at the very top end counter

and set it equal to zero.

And now we're going to increase the counter value by one after each question.

Counter plus plus here.

Counter plus plus.

Counter plus plus.

And do that two more times.

One last time.

Once the code gets to hear, the counter value should be five.

So at this point, we have the users values.

We counted the questions.

It's time to respond.

We're going to print a message that refers to the user by name, so system, dot, dot, print line.

We're going to say thank you.

Break the string and put the user's name.

And then we'll reconnect the string and say thank you, some name for answering all.

Break the string and put the counter value.

And then right questions at the end, so this should say thank you some person, for answering all X

amount of questions.

Let's recompile the code.

And runit.

What is your name?

Sam will say a dollar fifty four dollars and fifty cents.

Five and seven.

And check it out, the application responds.

It refers to the user by name and thanks them for answering all five questions.

Now, if you look at your terminal, the response and the last input are a bit squished, it looks kind

of awkward.

There there's a special symbol, again, that creates a new line of space, the backslash is an escape

character.

It tells Jarvis Stop the next character special and the character that follows is and where and again

creates a new line.

So in your code, we're going to add again at the beginning of our response.

All right, let's run our code.

And check it out, it does create a new line of space for us, Jarvis sees the slash in Java, knows

Slash is an escape character, sits there and creates a new line of space.

And after the new line, it prints the rest of the string as normal.

All right, we have that figured out now the app is going to tell the user how much more money they

spend on fast food over coffee.

So we'll say system dot out, dot print line.

Your fast food expenses are.

Break the string and here we'll need to divide the food price by the coffee price.

And we're going to blend the result of this operation as part of this long string, let's reconnect

another string that says times more than your coffee expenses.

When I recompile my code.

Your fast food expenses are three times more than your coffee expenses.

Notice that when decimals are involved in the operation, you get back a decimal.

All right, now we're going to tell the user how much they spend on coffee and food in a week, so we

need to multiply the amount and price for food and coffee.

System dart out the front line.

Weekly.

You spend.

In dollars.

Break the string and we're going to blend in the result of multiplying coffee amount by coffee price.

Then we'll reconnect the string to say on coffee.

We'll do the exact same thing for food system out front line.

Weekly you spend in dollars will blend in the result of multiplying the food amount by the food price.

And will conclude the string to say on food.

All right, the recompiling the code and running it, I'm going to fast forward.

And this looks good.

Once again, the result is a decimal because the price values are of type double.

Have another look at the final output.

You'll notice that an empty line precedes each question, so we're going to add a slash and before the

start of each question.

And here.

And here.

All right, rerun your app.

And notice now that the output looks a lot cleaner.

Congratulations, you built your first dynamic application in Java, the application starts by asking

these are questions and using scanner, it picks up each answer and stores it in a variable.

And now that we have every value stored in a variable, the application can respond.

As a final result, you built a fully interactive application where the user communicates with the app

and the app communicates back.

And that's all for your first dynamic up there is much more to come in this course, and I hope you're

excited.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.