-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
154 lines (123 loc) · 5.05 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Task 1: Add two numbers and display the result
var num1 = 5;
var num2 = 3;
var sum = num1 + num2;
document.write('Sum of ' + num1 + " and " + num2 + ' is ' + sum);
console.log('Sum of ' + num1 + " and " + num2 + ' is ' + sum);
// Task 2: Subtract, multiply, divide, and modulus find the remainder
var subtraction = num1 - num2;
var multiplication = num1 * num2;
var division = num1 / num2;
var modulus = num1 % num2;
document.write('subtraction:' + subtraction);
console.log('subtraction:' + subtraction);
document.write('multiplication:' + multiplication);
console.log('multiplication:' + multiplication);
document.write('division:' + division);
console.log('division:' + division);
document.write('modulus:' + modulus);
console.log('modulus:' + modulus);
// Task 3:
let myVariable; // Declare a variable
console.log('Value after variable declaration is:' + myVariable);
document.write('Value after variable declaration is:' + myVariable);
myVariable = 5; // Initialize the variable
console.log('Initial value: ' + myVariable);
document.write('Initial value: ' + myVariable);
myVariable++; // Increment the variable
console.log('Value after increment is:' + myVariable);
document.write('Value after increment is:' + myVariable);
myVariable += 7; // Add 7 to the variable
console.log('Value after addition is:' + myVariable);
document.write('Value after addition is:' + myVariable);
myVariable--; // Decrement the variable
document.write('Value after decrement is: ' + myVariable);
let remainderAfterDivision = myVariable % 3; // Calculate remainder
console.log('The remainder is: ' + remainderAfterDivision);
document.write('The remainder is: ' + remainderAfterDivision);
// Store the ticket price
var ticketPrice = 600;
// Calculate the cost of buying 5 tickets
var numberOfTickets = 5;
var totalCost = ticketPrice * numberOfTickets;
// Example output
console.log('The cost of buying' + numberOfTickets + 'tickets is ' + totalCost + 'PKR.');
document.write('The cost of buying' + numberOfTickets + 'tickets is ' + totalCost + 'PKR.');
var table = 4
var one = 1
var two = 2
var three = 3
var four = 4
var five = 5
var six = 6
var seven = 7
var eight = 8
var nine = 9
var ten = 10
console.log(table + ' * ' + one + ' = ' + table * one)
document.write(table + ' * ' + one + ' = ' + table * one)
console.log(table + ' * ' + two + ' = ' + table * two)
document.write(table + ' * ' + two + ' = ' + table * two)
console.log(table + ' * ' + three + ' = ' + table * three)
document.write(table + ' * ' + three + ' = ' + table * three)
console.log(table + ' * ' + four + ' = ' + table * four)
document.write(table + ' * ' + four + ' = ' + table * four)
console.log(table + ' * ' + five + ' = ' + table * five)
document.write(table + ' * ' + five + ' = ' + table * five)
console.log(table + ' * ' + six + ' = ' + table * six)
document.write(table + ' * ' + six + ' = ' + table * six)
console.log(table + ' * ' + seven + ' = ' + table * seven)
document.write(table + ' * ' + seven + ' = ' + table * seven)
console.log(table + ' * ' + eight + ' = ' + table * eight)
document.write(table + ' * ' + eight + ' = ' + table * eight)
console.log(table + ' * ' + nine + ' = ' + table * nine)
document.write(table + ' * ' + nine + ' = ' + table * nine)
console.log(table + ' * ' + ten + ' = ' + table * ten)
document.write(table + ' * ' + ten + ' = ' + table * ten)
// Step 1: Store a Celsius temperature into a variable
var celsiusTemp = 30;
// Step 2: Convert it to Fahrenheit & output
var fahrenheitTemp = (celsiusTemp * 9 / 5) + 32;
console.log(celsiusTemp + '°C is' + fahrenheitTemp.toFixed(2) + '°F');
// Step 3: Now store a Fahrenheit temperature into a variable
var fahrenheitTemp2 = 86;
// Step 4: Convert it to Celsius & output
var celsiusTemp2 = (fahrenheitTemp2 - 32) * 5 / 9;
console.log(fahrenheitTemp2.toFixed(2) + '°F is' + celsiusTemp2.toFixed(2) + '°C');
var car1 = 200;
var boykides2 = 500;
var totalcost = car1 + boykides2;
document.write("total cost of your order is" + totalcost);
console.log("total cost of your order is" + totalcost);
// totalmarks = prompt('Total marks');
// obtainmarks = prompt('obtain marks');
// alert((obtainmarks / totalmarks) * 100)
var sudi = 74;
var us = 278;
// sudiry = prompt('please add the Saudi Riyal\rconvert into PKR');
// alert(sudiry * sudi);
// usry = prompt('please add the US Dollar\rconvert into PKR');
// alert(usry * us);
var exp = (5 * 10) / 2;
console.log(exp);
document.write(exp);
// Get the current year
var currentYear = 2024;//new Date().getFullYear()
// Assume the birth year (you can replace this with the actual birth year)
var birthYear = 1990;
// Calculate the age based on the stored values
var age1 = currentYear - birthYear;
var age2 = age1 - 1; // The second possible age
// Output the results
console.log('They are either' + age1 + 'or' + age2 + 'years old.');
var radius = 20;
var circumference = 2 * 3.142 * radius;
var area = 3.142 * (radius * 2);
console.log(area);
console.log(circumference);
var favoritesnack = 'Lays';
var currentage = 15;
var maximumage = 65;
var estimatedamountperday = 3;
var Cal = (maximumage - currentage) * estimatedamountperday;
//By By//