-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
186 lines (115 loc) · 4.39 KB
/
index.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
document.write("<h1>Chapter 5</h1>");
var five = 5 ;
var three = 3;
var sumFivThr = five + three ;
document.write("The Sum of 3 and 5 is "+sumFivThr + "</br>");
var five = 5 ;
var three = 3;
var subFivThr = five - three ;
document.write("The Subtraction of 3 and 5 is "+subFivThr+ "</br>");
var five = 5 ;
var three = 3;
var mulFivThr = five * three ;
document.write("The Multiply of 3 and 5 is "+mulFivThr+ "</br>");
var five = 5 ;
var three = 3;
var divFivThr = five / three ;
document.write("The Division of 3 and 5 is "+divFivThr+ "</br>");
var five = 5 ;
var three = 3;
var modFivThr = five % three ;
document.write("The Modulus of 3 and 5 is "+modFivThr+"</br></br>");
//end
var myVariable;
document.write("Value after variable declaration is: " + myVariable + "<br>");
myVariable = 5;
document.write("Initial value: " + myVariable + "<br>");
myVariable++;
document.write("Value after increment is: " + myVariable + "<br>");
myVariable += 7;
document.write("Value after addition is: " + myVariable + "<br>");
myVariable--;
document.write("Value after decrement is: " + myVariable + "<br>");
var remainder = myVariable % 3;
document.write("The remainder is: " + remainder + "<br>");
//end
var ticket =600;
var buyTic= 5;
var result = ticket*buyTic;
document.write("</br>"+"Total Cost to buying "+buyTic+" ticket = "+result)
//end
document.write("<h2>Multiplication Table of 9</h2>");
for (var i = 1; i <= 10; i++) {
var resul = 9 * i;
document.write("9 x " + i + " = " + resul + "<br>");
}
//end
var celsiusTemperature = 28;
var fahrenheitTemperature = (celsiusTemperature * 9/5) + 32;
document.write("</br>"+celsiusTemperature + "°C is " + fahrenheitTemperature + "°F<br>");
var fahrenheitTemperature2 = 82;
var celsiusTemperature2 = (fahrenheitTemperature2 - 32) * 5/9;
document.write(fahrenheitTemperature2 + "°F is " + celsiusTemperature2.toFixed(2) + "°C");
//end
var priceItem1 = 650;
var priceItem2 = 100;
var quantityItem1 = 3;
var quantityItem2 = 7;
var shippingCharges = 100;
var totalCost = (priceItem1 * quantityItem1) + (priceItem2 * quantityItem2) + shippingCharges;
document.write("<h2>Shopping Cart:</h2>");
document.write("<p>Price of Item 1: " + priceItem1 + "</p>");
document.write("<p>Price of Item 2: " + priceItem2 + "</p>");
document.write("<p>Ordered Quantity of Item 1: " + quantityItem1 + "</p>");
document.write("<p>Ordered Quantity of Item 2: " + quantityItem2 + "</p>");
document.write("<p>Shipping Charges: " + shippingCharges + "</p>");
document.write("<p>Total Cost: " + totalCost + "</p>");
//end
var tot =980;
var obtain = 804;
var res = (obtain/tot)*100;
document.write("<h2>Result</h2>");
document.write("<p>Total Marks: " +tot+ "</p>");
document.write("<p>Marks Obtained: " +obtain+ "</p>");
document.write("<p>Percentage: " + res.toFixed(3) + "%</p>");
//end
document.write("</br>"+"<h2>Currency in PKR</h2>");
var dollar = 286.95;
var saudiRiyal=76.52;
var totalC = (10*dollar)+(25*saudiRiyal);
document.write("Total currency is "+totalC + "</br>");
//end
document.write("</br>"+"</br>"+"In 4 Add 5\n Multiply by 10\n Divide the result by 2");
var cal =4;
var resul = ((cal+5)*10)/2;
document.write("</br>"+resul);
//end
document.write("<h2>Age Calculator</h2>")
var birthYear = +prompt("Enter your right Birthyear..!")
var currentYear = 2023;
var truthAge = currentYear-birthYear;
document.write(birthYear+" the year you born </br>");
document.write(currentYear+" the current year</br>");
document.write(truthAge+" your<sup>,</sup>s truth age ...");
//end
document.write("</br><h2>The Geometrize:</h2>")
var radius = 20
var circumference= 125.67999999999999;
var area = Math.PI * radius * radius ;
document.write("The radius is "+radius+"</br>");
document.write("The circumference is " + circumference+"</br>");
document.write("The area is " + area.toFixed(2));
//end
document.write("<h2>The Lifetime Supply Calculator:</h2>");
var favoriteSnack = "Chocolate bars";
var currentAge = 30;
var maximumAge = 80;
var amountPerDays = 2;
var remainingYears = maximumAge - currentAge;
var totalQuantity = remainingYears * 365 * amountPerDays;
document.write("Your favorite snack: " + favoriteSnack+"</br>");
document.write("Current Age: " + currentAge+"</br>");
document.write("Maximum Age: " + maximumAge+"</br>");
document.write("Estimated amount per day: " + amountPerDays+"</br>");
document.write("Total quantity for the rest of your life: " + totalQuantity+"</br>");
//end