Language Esstentials II

24 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€49.04
List Price:  €68.66
You save:  €19.62
£41.29
List Price:  £57.81
You save:  £16.51
CA$72.16
List Price:  CA$101.03
You save:  CA$28.87
A$81.44
List Price:  A$114.03
You save:  A$32.58
S$68.72
List Price:  S$96.22
You save:  S$27.49
HK$389.25
List Price:  HK$544.98
You save:  HK$155.73
CHF 45.84
List Price:  CHF 64.18
You save:  CHF 18.34
NOK kr575.55
List Price:  NOK kr805.82
You save:  NOK kr230.26
DKK kr365.89
List Price:  DKK kr512.28
You save:  DKK kr146.38
NZ$90.17
List Price:  NZ$126.25
You save:  NZ$36.07
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.45
৳6,133.80
List Price:  ৳8,587.81
You save:  ৳2,454.01
₹4,328.18
List Price:  ₹6,059.80
You save:  ₹1,731.61
RM225.45
List Price:  RM315.65
You save:  RM90.20
₦77,784.93
List Price:  ₦108,905.13
You save:  ₦31,120.20
₨14,002.99
List Price:  ₨19,605.31
You save:  ₨5,602.31
฿1,740.67
List Price:  ฿2,437.08
You save:  ฿696.41
₺1,774.57
List Price:  ₺2,484.54
You save:  ₺709.97
B$309.75
List Price:  B$433.67
You save:  B$123.92
R959.85
List Price:  R1,343.87
You save:  R384.01
Лв95.70
List Price:  Лв134
You save:  Лв38.29
₩73,560.84
List Price:  ₩102,991.07
You save:  ₩29,430.22
₪183.60
List Price:  ₪257.06
You save:  ₪73.45
₱2,940.43
List Price:  ₱4,116.84
You save:  ₱1,176.41
¥7,853.94
List Price:  ¥10,996.14
You save:  ¥3,142.20
MX$1,041.47
List Price:  MX$1,458.14
You save:  MX$416.67
QR183.31
List Price:  QR256.65
You save:  QR73.33
P707.66
List Price:  P990.78
You save:  P283.12
KSh6,473.70
List Price:  KSh9,063.70
You save:  KSh2,590
E£2,524.94
List Price:  E£3,535.13
You save:  E£1,010.18
ብር6,309.33
List Price:  ብር8,833.56
You save:  ብር2,524.23
Kz45,632.53
List Price:  Kz63,889.20
You save:  Kz18,256.66
CLP$50,494.94
List Price:  CLP$70,696.96
You save:  CLP$20,202.02
CN¥366.52
List Price:  CN¥513.16
You save:  CN¥146.64
RD$3,086.60
List Price:  RD$4,321.50
You save:  RD$1,234.89
DA6,816.58
List Price:  DA9,543.76
You save:  DA2,727.18
FJ$116.93
List Price:  FJ$163.72
You save:  FJ$46.78
Q388.03
List Price:  Q543.27
You save:  Q155.24
GY$10,519.77
List Price:  GY$14,728.52
You save:  GY$4,208.75
ISK kr7,086.58
List Price:  ISK kr9,921.78
You save:  ISK kr2,835.20
DH505.35
List Price:  DH707.53
You save:  DH202.18
L938.43
List Price:  L1,313.88
You save:  L375.44
ден3,017.78
List Price:  ден4,225.13
You save:  ден1,207.35
MOP$403.21
List Price:  MOP$564.53
You save:  MOP$161.31
N$955.63
List Price:  N$1,337.96
You save:  N$382.32
C$1,850.30
List Price:  C$2,590.57
You save:  C$740.27
रु6,923.44
List Price:  रु9,693.37
You save:  रु2,769.93
S/189.20
List Price:  S/264.90
You save:  S/75.69
K201.57
List Price:  K282.22
You save:  K80.64
SAR187.65
List Price:  SAR262.73
You save:  SAR75.07
ZK1,388.98
List Price:  ZK1,944.69
You save:  ZK555.70
L243.90
List Price:  L341.48
You save:  L97.58
Kč1,233.80
List Price:  Kč1,727.43
You save:  Kč493.62
Ft20,312.76
List Price:  Ft28,439.49
You save:  Ft8,126.73
SEK kr564.66
List Price:  SEK kr790.58
You save:  SEK kr225.91
ARS$51,827.38
List Price:  ARS$72,562.48
You save:  ARS$20,735.10
Bs347.42
List Price:  Bs486.41
You save:  Bs138.99
COP$218,754.20
List Price:  COP$306,273.38
You save:  COP$87,519.18
₡25,380.11
List Price:  ₡35,534.18
You save:  ₡10,154.07
L1,278.71
List Price:  L1,790.30
You save:  L511.58
₲394,811.50
List Price:  ₲552,767.69
You save:  ₲157,956.19
$U2,184.20
List Price:  $U3,058.06
You save:  $U873.85
zł209.47
List Price:  zł293.28
You save:  zł83.80
Already have an account? Log In

Transcript

Okay now we go into the language essentials part two. So in this chapter, we are going to look into conditional statements. Then we are going to go into the loops and then we are going to go into our methods. Okay our console calculator current Neo Nipa forma addition of two numbers. So how do we extend the program to have subtraction, multiplication and division so require allow the user to have the option to choose whether to perform addition subtraction, multiplication or division. The program is a vertical addition subtraction, multiplication and division on two numbers and by user.

Okay, so I will say these are two new requirements. So we have to modify the previous code as follows. Okay, so I'll be using a switch statement here. Okay, so as usual we create a new skin object. Then the gray brina tight, tighter here, my first console calculator, and we print the menu addition, subtraction, multiplication or division. Then we got the user input.

There is usually kinda first time but Second number there we do the calculation okay if I say user employees one then we do addition to the subtraction tree we do multiplication for we do the division then the fall we do it be display error every continue to create a result okay so we create a scanner object okay the skin okay. Console calculator then we are supposed to create a menu system da da da, green lie. So why knees condition a new lie to will be subtraction. Then treat the multiplication product and following the deviation okay? Then a semicolon and we are supposed to get a user info for the ah data selection whether to do addition or subtraction. So we do the stream stream SDI auto ID okay?

Sc dot exe key. Okay then you press Enter first number Press Enter second number Okay Davo Patil first and second number. Okay, here we go. Okay, SDI input okay. So we do case ah case one case one case one is addition. So if user input one, so we do addition.

So it should be dv number dv number one bras, db number two and we see two doubles who one key resolve one equals zero okay resolve one equal DB one plus the number okay case to resolve one DB one minus TV number two okay then we have case three resolved on equal DB number Number one times the V number two k v k is four resolve the DB number one, the vida by DB number two. Okay. Yeah, so default system dot out. dot println ly arrow key and DB resolve on we can remove this one okay Can we do the same? Okay, let me run the code So Eddie shows up subtraction protein division so I To one oh first number one two okay please ah there we have era 0.5 though uplines Oh okay. So they some error.

So this is why we should integrate here. Key Shane here he he the He will not in the break here. He will go from one to case two and then case three case four. So we have to break. So after case why and then you break out this system. Okay, so we have to run the program again Okay, let's see I do addition now.

So first number one, two, it gives me three. So this is the correct one if I run again K One, two, negative one K so this is subtraction. Okay, subtraction One, two Negative one and there we have three boys multiplication and division as low as code in Java programming for all the Lord God conditioners a man we have two types. Gay we have the eve hours and switch schema. So in our code we use his switch statement key. So I say I'm using the if statement to be if a user employee equate equal to one that do as a result will result equal First number plus second number LC, a user employees equal equal to two, the end result equals first number minus second number.

So essentially the same. So in system in the first condition I Eve user input equal equal to one, there'll be a comma case one and we do the Samadhi addition. So, for the second contrast question LC ah let's say user input equal equal to two. In the system it will be case two. And then for the and then it continues on until else LC default in the switch statement. So in conditional statement, we use our equal equal to represent equal to this exclamation mark and equally to represent not equal to 10 less than, less than or equal to, greater than, and greater than or equal to, then we have n, then all.

So adding logic to the calculator, so we modify the console calculator. Now we faced two new problems that need to be solved. So if the user entered the wrong option, the program will still prompt the user to enter the first and second number before displaying the errors. The program only run once and your shadow. So how are we going to do Use the if else statement to solve the first problem. Okay, the first problem will be if the user enter the run option, the program will still prompt the user to enter first number and second number before the spring the errors.

So to do that we if statement down here. So if a user input option is more than zero, and option is less than or equal to zero, then we execute all the code here. Even though we display error, okay. So let's modify the code okay. Okay string user input. So I will say integer option, integer option is integer no pass in teacher Okay, so should we pass in teacher Okay, SDI semi colon, okay.

So a Eve option is ah, so we stopping to pay for it often is more than or equal to one and then option is less than or equal to fall. Okay open braces. And we do here Sit down dog. Okay? Cause racer here. Else system dot out.

Dot println lie era Okay, so now I can remove this one here can comment up okay? Okay, so I run this program can you sleep? No I ain't see ah zero Ci into zero should give me error. So he one asked me to enter the first number and second number he will straightaway come to IRA okay so let us see those slides like Sony

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.