File tree Expand file tree Collapse file tree 3 files changed +92
-0
lines changed Expand file tree Collapse file tree 3 files changed +92
-0
lines changed Original file line number Diff line number Diff line change 1+ /*** problem-6
2+
3+ Ticket fare Calculator
4+ - Children (age < 10): free
5+ - Students get a 50% discount
6+ - Senior citizens (age >= 60) gets a 15% Discount
7+ - Otherwise Regular ticket fare 800 tk
8+ */
9+
10+ let age = 20 ;
11+ let ticketPrice = 800 ;
12+ let isStudent = true ;
13+
14+ if ( age < 10 ) {
15+ console . log ( "Free" ) ;
16+ }
17+ else if ( isStudent === true ) {
18+ // discount price
19+ studentDiscount = ticketPrice * 50 / 100 ;
20+ console . log ( studentDiscount ) ;
21+
22+ }
23+ else if ( age >= 60 ) {
24+ // discount price
25+ seniorCitizenDiscount = ticketPrice * 85 / 100 ;
26+ console . log ( seniorCitizenDiscount ) ;
27+ }
28+
29+ else {
30+ console . log ( "Regular ticket fare 800 tk" ) ;
31+ }
Original file line number Diff line number Diff line change 1+ /*** problem-4
2+
3+ if you get more then 80 then inside your friend score.
4+ If your friend get more than 80. then go for a lunch.
5+ if your friend get below 80 but greater than or equal 60 then tell your friend, good luck next time.
6+ if your friend get less than 60 but more than or equal to 40 then, keep your friend's message unseen.
7+ if your friend get less than 40, block your friend
8+ if you get less than 80 go to home and sleep and act sad
9+
10+ Note:
11+ use nested if-else-if-else
12+ */
13+ let myMarks = 100 ;
14+ let friendMarks = 100 ;
15+ if ( myMarks < 80 ) {
16+ console . log ( "I sleep and feelings so sad" ) ;
17+ }
18+ else {
19+ if ( myMarks > 101 || friendMarks > 101 ) {
20+ console . log ( "Invalid Marks" ) ;
21+ }
22+ else if ( friendMarks > 80 ) {
23+ console . log ( "We will go for lunch." ) ;
24+ }
25+ else if ( friendMarks < 80 && friendMarks >= 60 ) {
26+ console . log ( "Good luck next time." ) ;
27+ }
28+ else if ( friendMarks < 60 && friendMarks >= 40 ) {
29+ console . log ( "Keep your friend's message unseen." ) ;
30+ }
31+ else {
32+ console . log ( "I block friend" ) ;
33+ }
34+ }
Original file line number Diff line number Diff line change 1+ /*** problem-5
2+
3+ you have two numbers in two variables, called: num1, num2
4+
5+ now declare a variable called result.
6+ if num1 is bigger than num2 then result will be double of num1. if not, then the value of the variable result will be the sum of num1 and num2.
7+
8+ write a simple if-else.
9+
10+ also, write it using ternary operator.
11+
12+ */
13+ let num1 = 10 ;
14+ let num2 = 5 ;
15+
16+ // simple if-else.
17+ if ( num1 > num2 ) {
18+ console . log ( num1 * 2 ) ;
19+ }
20+ else {
21+ sum = num1 + num2 ;
22+ console . log ( sum ) ;
23+ }
24+
25+ // ternary
26+ let numbers = num1 > num2 ? num1 * 2 : num1 + num2 ;
27+ console . log ( numbers ) ;
You can’t perform that action at this time.
0 commit comments