Advertisement
Guest User

IWP

a guest
Oct 28th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.77 KB | None | 0 0
  1. Paste2
  2. Create Paste
  3. Followup Paste
  4. QR
  5. Internet And Web Programming
  6. LAB 1
  7.  
  8. Activity 1:
  9. CODE:
  10. <html>
  11. <title>
  12. Enrollment Application
  13. </title>
  14. <head>
  15. </head>
  16. <center>
  17. <h1 style="color:blue">
  18. VIT Student FOOTBALL TEAM Application
  19. </h1>
  20. <img src="http://vit.ac.in/images/logo1.png" width="300" length="300">
  21.  
  22. <body>
  23. <p style="color:white">VISIT VIT, A PLACE TO LEARN, A CHANCE TO
  24. GROW</p>
  25. <a href="http://vit.ac.in">Click here</a><br><br>
  26. <table>
  27. <tr>
  28. <td>First Name:</td>
  29. <td><input type="text" name="fname"><br></td>
  30. </tr>
  31. <tr>
  32. <td>Last Name:</td>
  33. <td><input type="text" name="lname"></td>
  34. </tr>
  35. <tr>
  36. <td>Age:</td>
  37. <td><input type="number" name="age" min="0"></td>
  38. </tr>
  39. <tr>
  40. <td>Reg.No:</td>
  41. <td><input type="text" name="regno" min="9" max="9"><br></td>
  42. </tr>
  43. <tr>
  44. <td>Email:</td>
  45. <td><input type="email" name="mail"></td>
  46. </tr>
  47. <tr>
  48. <td>School:</td>
  49. <td><input type="radio" name="cse">SCOPE<br>
  50. <input type="radio" name="ece">SENSE<br>
  51. <input type="radio" name="mech">SMEC<br>
  52. <input type="radio" name="eee">SELECT<br>
  53. </td>
  54. </tr>
  55. <tr>
  56. <td>CGPA:</td>
  57. <td><input type="range" name="cgpa" min="0,0" max="10.0"></td>
  58. </tr>
  59. <tr>
  60. <td>Interested Position: </td>
  61. <td><input type="checkbox" name="cp">Striker<br>
  62. <input type="checkbox" name="ch">Defender<br>
  63. <input type="checkbox" name="sh">MIdfielder<br>
  64. <input type="checkbox" name="ah">Goalkeeper<br>
  65. </td>
  66. </tr>
  67. <tr>
  68. <td>Student Password:</td>
  69. <td><input type="password" name="pass" required></td>
  70. </tr>
  71.  
  72. <tr>
  73. <td>Date & Time:</td>
  74. <td><input type="datetime-local"></td>
  75. </tr>
  76.  
  77. </table>
  78. <br>
  79. <input type="submit">&emsp;&emsp;&emsp;<input type="reset">
  80. </body>
  81. </center>
  82. </html>
  83. Activity 2:
  84. CODE:
  85. <!DOCTYPE html>
  86. <!--
  87. To change this license header, choose License Headers in Project Properties.
  88. To change this template file, choose Tools | Templates
  89. and open the template in the editor.
  90. -->
  91. <html>
  92. <style> { background-color: green; } </style>
  93. <head>
  94. <title>My Resume</title>
  95. <meta charset="UTF-8">
  96. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  97. </head>
  98. <body>
  99. <div id="header"></div>
  100. <div class="left"></div>
  101. <div class="stuff">
  102. <br><br>
  103. <h2>BELAL AHMED</h2>
  104. <hr />
  105. <br>
  106. <p class="head">Interests</p>
  107. <ul>
  108. <li>Football</li>
  109. <li>Photography</li>
  110. <li>Design</li>
  111. <li>Programming</li>
  112. <li>Computer Science</li>
  113. </ul>
  114. <p class="head">Skills</p>
  115. <ul>
  116. <li>Web Design with HTML & CSS</li>
  117. </ul>
  118. <p class="head">Education</p>
  119. <ul>
  120. <li>St.Joseph Academy</li>
  121. <li>VIT UNIVERSITY</li>
  122. </ul>
  123. <p class="head">Experience</p>
  124. <ul>
  125. <li>ACM Club Chapter</li>
  126. <li>Intern At Oil And Natural Gas Corporation</li>
  127. </ul>
  128. <p class="head">Extracurriculars</p>
  129. <ul>
  130. <li>Football</li>
  131. <li>Cricket</li>
  132. <li>Book Club</li>
  133. </ul>
  134. </div>
  135. <div class="right"></div>
  136. <div id="footer">
  137. <h2 id="name">Belal</h2></div>
  138.  
  139. </body>
  140. </html>
  141. Activity 3:
  142. CODE:
  143. <!DOCTYPE html>
  144. <html>
  145. <body>
  146. <audio controls>
  147. <source src="horse.ogg" type="audio/ogg">
  148. <source src="horse.mp3" type="audio/mpeg">
  149. Your browser does not support the audio element.
  150. </audio>
  151. <video width="320" height="240" controls>
  152. <source src="movie.mp4" type="video/mp4">
  153. <source src="movie.ogg" type="video/ogg">
  154. Your browser does not support the video tag.
  155. </video>
  156. </body>
  157. </html>
  158. Activity 4:
  159. CODE:
  160. <!DOCTYPE html>
  161. <html>
  162. <head>
  163. <style>
  164. div {
  165. border: 25px solid green;
  166. padding: 25px;
  167. margin: dashed;
  168. margin: 25px;
  169. text-align:center;
  170. width: 500px;
  171. background-color:white;
  172. border-top-color:yellow;
  173. outline-width: dashed;
  174. }
  175. </style>
  176. </head>
  177. <body>
  178. <div>BILAL AHMED</div>
  179. </body>
  180. </html>
  181. Activity 5:
  182. CODE:
  183. <!DOCTYPE html>
  184. <html>
  185. <head>
  186. <style>
  187. ul {
  188. list-style: none;
  189. padding: 0;
  190. margin: 0;
  191. background: green;
  192. }
  193. ul li {
  194. display: block;
  195. position: relative;
  196. float: left;
  197. background: green;
  198. }
  199. li ul { display: none; }
  200. ul li a {
  201. display: block;
  202. padding: 1em;
  203. text-decoration: none;
  204. white-space: nowrap;
  205. color: #fff;
  206. }
  207. ul li a:hover { background: red; }
  208. li:hover > ul {
  209. display: block;
  210. position: absolute;
  211. }
  212. li:hover li { float: none; }
  213. li:hover a { background: #1bc2a2; }
  214. li:hover li a:hover { background: green; }
  215. .main-navigation li ul li { border-top: 0; }
  216. ul ul ul {
  217. left: 100%;
  218. top: 0;
  219. }
  220. ul:before,
  221. ul:after {
  222. content: " "; /* 1 */
  223. display: table; /* 2 */
  224. }
  225. ul:after { clear: both; }
  226. </style>
  227. </head>
  228. <body>
  229. <ul class="main-navigation">
  230. <li><a href="#">Home</a></li>
  231. <li><a href="#">Teacher</a>
  232. <ul>
  233. <li><a href="#">SENSE</a></li>
  234. <li><a href="#">SITE</a>
  235. <li><a href="#">SCOPE</a>
  236. <ul>
  237. <li><a href="#">Nalini N</a></li>
  238. <li><a href="#">Lokesh KUmar</a></li>
  239. <li><a href="#">Arun Kumar S</a></li>
  240. </ul>
  241. </li>
  242. </ul>
  243. </li>
  244. <li><a href="#">Staff</a>
  245. </li>
  246. <li><a href="#">About</a></li>
  247. </ul>
  248. </body>
  249. </html>
  250. Activity 6:
  251. CODE:
  252. <!DOCTYPE html>
  253. <html>
  254. <head>
  255. <style>
  256. body
  257. {background-color: #ddd;
  258. text-align:center;
  259. }
  260. h5 {color:red;}
  261. p.dotted {border-style: dotted;}
  262. p.dashed {border-style: dashed;}
  263. p.solid {border-style: solid;}
  264. p.double {border-style: double;}
  265. p.groove {border-style: groove;}
  266. p.ridge {border-style: ridge;}
  267. p.inset {border-style: inset;}
  268. p.outset {border-style: outset;}
  269. p.none {border-style: none;}
  270. p.hidden {border-style: hidden;}
  271. p.mix {border-style: dotted dashed solid double;}
  272. </style>
  273. </head>
  274. <body>
  275. <table>
  276. <tr>
  277. <td>
  278. <p class="none">No border.</p>
  279. <p class="dotted">A dotted border.</p>
  280. <p class="dashed">A dashed border.</p>
  281. <p class="solid">A solid border.</p>
  282. <p class="double">A double border.</p>
  283. </td>
  284. <td>
  285. <p class="groove">A groove border.</p>
  286. <p class="ridge">A ridge border.</p>
  287. <p class="inset">An inset border.</p>
  288. <p class="outset">An outset border</p>
  289. <p class="hidden">A hidden border.</p>
  290. </td>
  291. </tr>
  292. </table>
  293. </body>
  294. </html>
  295. Activity 7:
  296. CODE:
  297. Question 7
  298. <html>
  299. <head>
  300. <style>
  301. table, th, td {
  302. border: 1px solid black;
  303. border-collapse: collapse;
  304. }
  305. .hovertable tr:hover {
  306. background-color: yellow;
  307. }
  308. td{
  309. padding: 15px;
  310. }
  311. </style>
  312. </head>
  313. <body>
  314. <table class="hovertable">
  315. <tr style='background-color: skyblue'>
  316. <td>#</td>
  317. <td>IMDB Top 10 Movies</td>
  318. <td>Year</td>
  319. </tr>
  320. <tr onmouseover="ChangeBackgroundColor(red)"
  321. onmouseout="RestoreBackgroundColor(white)">
  322. <td>1</td>
  323. <td>The Shawshank Redemption</td>
  324. <td>1994</td>
  325. </tr>
  326. <tr>
  327. <td>2</td>
  328. <td>The Godfather</td>
  329. <td>1972</td>
  330. </tr>
  331. <tr>
  332. <td>3</td>
  333. <td>The Godfather:PartII</td>
  334. <td>1974</td>
  335. </tr>
  336. <tr>
  337. <td>4</td>
  338. <td>The Good,the Bad and the Ugly</td>
  339. <td>1966</td>
  340. </tr>
  341. <tr>
  342. <td>5</td>
  343. <td>Pulp Fiction</td>
  344. <td>1994</td>
  345. </tr>
  346. <tr>
  347. <td>6</td>
  348. <td>12 Angry Men</td>
  349. <td>1957</td>
  350. </tr>
  351. <tr>
  352. <td>7</td>
  353. <td>Schindler's list</td>
  354. <td>1993</td>
  355. </tr>
  356. <tr>
  357. <td>8</td>
  358. <td>One Flew Over the Cuckoo's Nest</td>
  359. <td>1975</td>
  360. </tr>
  361. <tr>
  362. <td>9</td>
  363. <td>The Dark Knight</td>
  364. <td>2008</td>
  365. </tr>
  366. <tr>
  367. <td>10</td>
  368. <td>The Lord of the Rings: The Return of the King</td>
  369. <td>2003</td>
  370. </tr>
  371. </table>
  372. </body>
  373. </html>
  374. Activity 8:
  375. CODE:
  376. <!DOCTYPE html>
  377. <html>
  378. <head>
  379. <style>
  380. body{background-color: #ddd}
  381. #boxshadow {
  382. position: relative;
  383. -moz-box-shadow: 1px 2px 4px rgba(0, 0, 0,0.5);
  384. -webkit-box-shadow: 1px 2px 4px rgba(0, 0, 0, .5);
  385. box-shadow: 1px 2px 4px rgba(0, 0, 0, .5);
  386. padding: 10px;
  387. background: white;
  388. }
  389. #boxshadow::after {
  390. content: '';
  391. position: absolute;
  392. z-index: -1;
  393. -webkit-box-shadow: 0 15px 20px rgba(0, 0, 0, 0.3);
  394. -moz-box-shadow: 0 15px 20px rgba(0, 0, 0, 0.3);
  395. box-shadow: 0 15px 20px rgba(0, 0, 0, 0.3);
  396. width: 70%;
  397. left: 15%;
  398. height: 100px;
  399. bottom: 0;
  400. }
  401. div.test {
  402. white-space: nowrap;
  403. width: 200px;
  404. overflow: hidden;
  405. border: 1px solid #ddd;
  406. }
  407. div.test:hover {
  408. text-overflow: inherit;
  409. overflow: visible;
  410. }
  411. h1 {
  412. text-align:center;
  413. color: white;
  414. text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px green;
  415. }
  416. p.para1 {
  417. width: 15em;
  418. border: 1px solid #ddd;
  419. word-wrap: break-word;
  420. }
  421. s</style>
  422. </head>
  423. <body>
  424. <h1>INDIA</h1>
  425. <div id="boxshadow" align='center'>
  426. <br>
  427. <p><img src="https://www.w3schools.com/css/rock600x400.jpg" alt="Pineapple"
  428. style="width:170px;height:170px;margin-left:15px;">
  429. India (IAST: Bhārat), also called the Republic of India (IAST: Bhārat Gaṇarājya),[19][e] is a
  430. country in South Asia. It is the seventh-largest country by area, the second-most populous
  431. country (with over 1.2 billion people), and the most populous democracy in the world. It is
  432. bounded by the Indian Ocean on the south, the Arabian Sea on the southwest, and the Bay of
  433. Bengal on the southeast. It shares land borders with Pakistan to the west;[f] China, Nepal, and
  434. Bhutan to the northeast; and Bangladesh and Myanmar to the east. In the Indian Ocean, India
  435. is in the vicinity of Sri Lanka and the Maldives. India's Andaman and Nicobar Islands share a
  436. maritime border with Thailand and Indonesia.
  437. The Indian subcontinent was home to the urban Indus Valley Civilisation of the 3rd millennium
  438. BCE. In the following millennium, the oldest scriptures associated with Hinduism began to be
  439. composed. Social stratification, based on caste, emerged in the first millennium BCE, and
  440. Buddhism and Jainism arose. Early political consolidations took place under the Maurya and
  441. Gupta empires; the later peninsular Middle Kingdoms influenced cultures as far as southeast
  442. Asia. In the medieval era, Judaism, Zoroastrianism, Christianity, and Islam arrived, and
  443. Sikhism emerged, all adding to the region's diverse culture. Much of the north fell to the Delhi
  444. sultanate; the south was united under the Vijayanagara Empire. The economy expanded in the
  445. 17th century in the Mughal Empire. In the mid-18th century, the subcontinent came under
  446. British East India Company rule, and in the mid-19th under British crown rule. A nationalist
  447. movement emerged in the late 19th century, which later, under Mahatma Gandhi, was noted
  448. for nonviolent resistance and led to India's independence in 1947.
  449. In 2017, the Indian economy was the world's sixth largest by nominal GDP[20] and third largest
  450. by purchasing power parity.[16]Following market-based economic reforms in 1991, India
  451. became one of the fastest-growing major economies and is considered a newly industrialised
  452. country. However, it continues to face the challenges of poverty, corruption, malnutrition, and
  453. inadequate public healthcare. A nuclear weapons state and regional power, it has the second
  454. largest standing army in the world and ranks fifth in military expenditure among nations. India
  455. is a federal republic governed under a parliamentary system and consists of 29 states and 7
  456. union territories. It is a pluralistic, multilingual and multi-ethnic society and is also home to a
  457. diversity of wildlife in a variety of protected habitats.
  458. </p>
  459. </div>
  460. <br>
  461. <div class="test" style="text-overflow:ellipsis;"><b>India, the country of all</b></div>
  462. <br>
  463. <p class="para1">The earliest authenticated human remains in South Asia date to about 30,000
  464. years ago.[27] Nearly contemporaneous Mesolithic rock art sites have been found in many
  465. parts of the Indian subcontinent, including at the Bhimbetka rock shelters in Madhya
  466. Pradesh.[28]Around 7000 BCE, one of the first known Neolithic settlements appeared on the
  467. subcontinent in Mehrgarh and other sites in the subcontinent.[29] These gradually developed
  468. into the Indus Valley Civilisation,[30] the first urban culture in South Asia;[31] it flourished
  469. during 2500–1900 BCE in northeast Afghanistan to Pakistan and northwest India.[32] Centred
  470. around cities such as Mohenjo-daro, Harappa, Dholavira, and Kalibangan, and relying on
  471. varied forms of subsistence, the civilisation engaged robustly in crafts production and wideranging
  472. trade</p>
  473. </body>
  474. </html>
  475. EXPERIMENT NO 2
  476. BELAL AHMED
  477. 16BCE0281
  478. QUESTION 1:
  479. CODE:
  480. <!DOCTYPE html>
  481. <html>
  482. <head>
  483. <title></title>
  484. </head>
  485. <body>
  486. <p> The total value of the goods sold is :</p>
  487. <p id="total_disp"></p>
  488. <script>
  489. var i, total=0;
  490. for( i=0 ; i< 5; i++){
  491. var a = prompt("Enter the product number");
  492. a = parseInt(a);
  493. switch(a){
  494. default:
  495. alert("You have enetered wrong value");
  496. case 1:
  497. b = prompt('Enter quantity');
  498. b = parseInt(b);
  499. total += 2.98 * b;
  500. break;
  501. case 2:
  502. b = prompt('Enter quantity');
  503. b = parseInt(b);
  504. total += 3.98 *b;
  505. break;
  506. case 3:
  507. b = prompt('Enter quantity');
  508. b = parseInt(b);
  509. total += 5 * b;
  510. break;
  511. case 4:
  512. b = prompt('Enter quantity');
  513. b = parseInt(b);
  514. total += 10 *b;
  515. break;
  516. case 5:
  517. b = prompt('Enter quantity');
  518. b = parseInt(b);
  519. total += 20 * b;
  520. break;
  521. }
  522. }
  523. document.getElementById('total_disp').innerHTML = total;
  524. </script>
  525. </body>
  526. </html>
  527. OUTPUT:
  528. QUESTION 2:
  529. CODE:
  530. <!DOCTYPE html>
  531. <html>
  532. <head>
  533. <title>slide</title>
  534. <style>
  535. div {text-align: center}
  536. </style>
  537. <script>
  538.  
  539. var
  540. x=["https://www.w3schools.com/html/pic_trulli.jpg","https://www.w3schools.com/html/img
  541. _girl.jpg","https://www.w3schools.com/html/img_chania.jpg"];
  542. var z=0;
  543. function slide()
  544. {
  545. var y=x.length;
  546. document.getElementById('img1').src=x[z%y];
  547. z=z+1;
  548. }
  549. function change()
  550. {
  551. var e=document.getElementById('change').value;
  552. x.push(e);
  553. }
  554. </script>
  555. </head>
  556. <body>
  557. <div>
  558. <img src="https://www.w3schools.com/html/img_chania.jpg" alt="Flowers in Chania"
  559. id="img1" onclick="slide()" height="300" width="500">
  560. <br>
  561. <button onclick="slide()" type="textbox">change</button>
  562. <input name="Imagelink" type="text" id="change">
  563. <button type="submit" onclick="change()" value="Add">Add</button>
  564. </div>
  565. </body>
  566. </html>
  567. OUTPUT:
  568. QUESTION 3:
  569. CODE:
  570. <!DOCTYPE html>
  571. <html>
  572. <head>
  573. <title>Random</title>
  574. <meta charset="UTF-8">
  575. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  576.  
  577. <script>
  578. function ABC()
  579. {
  580. x=Math.floor(Math.random()*300);
  581. document.getElementById("IMG1").width=x;
  582. y=Math.floor(Math.random()*300);
  583. document.getElementById("IMG1").height=y;
  584.  
  585. }
  586.  
  587. </script>
  588. </head>
  589. <body>
  590. <div>
  591. <img src="https://www.w3schools.com/html/img_girl.jpg" alt="Img" id="IMG1"
  592. width="300" height="300" onclick="ABC()"/>
  593. <button onclick="ABC()">Random</button>
  594.  
  595. </div>
  596. </body>
  597.  
  598. </html>
  599. OUTPUT:
  600. EXPERIMENT NO 3
  601. BELAL AHMED
  602. 16BCE0281
  603. CODE:
  604. <!DOCTYPE html>
  605. <html>
  606. <head>
  607. <title>Digital Clock</title>
  608. <style>
  609. .clock {
  610. top: 50%;
  611. left: 50%;
  612. color: white;
  613. font-family: sans-serif;
  614. font-size: 60px;
  615. letter-spacing: 7px;
  616. text-align: center;
  617. }
  618. .day{
  619. color: white;
  620. }
  621. ul li{
  622. display: inline;
  623. color: darkgrey;
  624. }
  625. ul{
  626. word-spacing: 7px;
  627. padding: 0px;
  628. font-family: sans-serif;
  629. text-align: center;
  630. }
  631. .bound{
  632. border:35px solid grey;
  633. background-color: black;
  634. width: 100%;
  635. }
  636. .corner{
  637. position: fixed;
  638. bottom: 0;
  639. right: 70px;
  640. }
  641. </style>
  642. </head>
  643. <body>
  644. <div class="corner">
  645. <div id="boundary" class="bound">
  646. <ul>
  647. <li id="Mon">Mon</li>
  648. <li id="Tues">Tue</li>
  649. <li id="Wed">Wed</li>
  650. <li id="Thu">Thu</li>
  651. <li id="Fri">Fri</li>
  652. <li id="Sat">Sat</li>
  653. <li id="Sun">Sun</li>
  654. </ul>
  655. <div id="ClockDisplay" class="clock"></div>
  656. <div id="DayDisplay" class="day"> </div>
  657. </div>
  658. <script>
  659. function showTime()
  660. {
  661. var date = new Date();
  662. var h = date.getHours();
  663. var m = date.getMinutes();
  664. var s = date.getSeconds();
  665. h=(h<10)?"0"+h:h;
  666. m=(m<10)?"0"+m:m;
  667. s=(s<10)?"0"+s:s;
  668. var time=h+":"+m+":"+s;
  669. document.getElementById("ClockDisplay").innerText=time;
  670. document.getElementById("ClockDisplay").textContent=time;
  671. var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
  672. var curWeekDay = days[date.getDay()];
  673. var day = curWeekDay;
  674. switch(day)
  675. {
  676. case "Mon":
  677. document.getElementById("Mon").style.color="white";
  678. break;
  679. case "Tue":
  680. document.getElementById("Tue").style.color="white";
  681. break;
  682. case "Wed":
  683. document.getElementById("Wed").style.color="white";
  684. break;
  685. case "Thu":
  686. document.getElementById("Thu").style.color="white";
  687. break;
  688. case "Fri":
  689. document.getElementById("Fri").style.color="white";
  690. break;
  691. case "Sat":
  692. document.getElementById("Sat").style.color="white";
  693. break;
  694. case "Sun":
  695. document.getElementById("Sun").style.color="white";
  696. break;
  697. }
  698. setTimeout(showTime, 1000);
  699. }
  700. showTime();
  701. </script>
  702. </div>
  703. </body>
  704. </html>
  705. OUTPUT:
  706. EXPERIMENT NO 4
  707. 16BCE0281
  708. BELAL AHMED
  709. CODE:
  710. Sale.php
  711. <html>
  712. <head>
  713. <title>
  714. Car Amount Calculator
  715. </title>
  716. <style>
  717. table,
  718. td,
  719. tr {
  720. border: 1px solid black;
  721. border-collapse: collapse;
  722. }
  723. </style>
  724. </head>
  725. <body>
  726. <h1>
  727. Please enter the following details.
  728. </h1>
  729. <form name =”16bce0281”method="post" action='action.php'>
  730. <table>
  731. <tr>
  732. <td>
  733. Car Plate:
  734. </td>
  735. <td>
  736. <input type="text" name="car_plate" placeholder="Plate number">
  737. </td>
  738. </tr>
  739. <tr>
  740. <td>
  741. Car Brand:
  742. </td>
  743. <td>
  744. <select name="car_brand" required>
  745. <option value="astra">Astra</option>
  746. <option value="civic">Civic</option>
  747. <option value="megane">Megane</option>
  748. </select>
  749. </td>
  750. </tr>
  751. <tr>
  752. <td>
  753. Airbag:
  754. </td>
  755. <td>
  756. <input type="checkbox" name="airbag">
  757. </td>
  758. </tr>
  759. <tr>
  760. <td>
  761. Engine:
  762. </td>
  763. <td>
  764. <input type="radio" value="e_16" name="engine" required> 1.6
  765. <input type="radio" value="e_18" name="engine" required>1.8
  766. <input type="radio" value="e_20" name="engine" required>2.0
  767. </td>
  768. </tr>
  769. <tr>
  770. <td colspan="2" style="text-align: center;">
  771. <input type="submit" value="Calculate" name="calc">
  772. </td>
  773. </tr>
  774. </table>
  775. </form>
  776. </body>
  777. </html>
  778. action.php
  779. <html>
  780. <body>
  781. <?php
  782. $car_price = $car = $engine_price = $car_plate = 0;
  783. $airbag_price = $total = 0;
  784. if($_SERVER['REQUEST_METHOD']=='POST'){
  785. $car_plate = $_POST['car_plate'];
  786. if(!preg_match("^[0-9]{2} [aA-zZ]{1,3} [0-9]{2,4}$^", $car_plate)){
  787. echo "Car Plate number is invalid";
  788. }
  789. else{
  790. $car = $_POST['car_brand'];
  791. switch($car){
  792. case "astra":
  793. $car_price = 20000;
  794. break;
  795. case "civic":
  796. $car_price = 25000;
  797. break;
  798. case "megane":
  799. $car_price = 18000;
  800. break;
  801. }
  802. $engine_price = $_POST["engine"];
  803. switch($engine_price){
  804. case "e_16":
  805. $engine_price = 1.6;
  806. break;
  807. case "e_18":
  808. $engine_price = 1.8;
  809. break;
  810. case "e_20":
  811. $engine_price = 2.0;
  812. break;
  813. }
  814. if(isset($_POST["airbag"]) && !empty($_POST["airbag"])){
  815. $airbag_price = 2000;
  816. }
  817. // Debugging purposes
  818. // echo $car;
  819. // echo $car_price;
  820. // echo "\n";
  821. // echo $engine_price;
  822. // echo "\n";
  823. // echo $airbag_price;
  824. $total = $car_price * $engine_price + $airbag_price;
  825. echo "Total price for ",$_POST['car_brand'] ," ",$total," TL";
  826. echo $total;
  827. }
  828. }
  829. ?>
  830. <br>
  831. <a href="sale.php">Back</a>
  832. </body>
  833. </html>
  834. OUTPUT:
  835.  
  836. EXPERIMENT NO.5
  837. 16BCE0281
  838. BELAL AHMED
  839. Code:
  840. lab.php
  841. <html>
  842. <head>
  843. <title>
  844. 16BCE0281
  845. </title>
  846. <meta charset="utf-8" />
  847. <style>
  848. table,
  849. th,
  850. td {
  851. border: 1px solid black;
  852. border-collapse: collapse;
  853. }
  854.  
  855. td {
  856. width: auto;
  857. }
  858.  
  859. .button {
  860. text-decoration: underline;
  861. color: purple;
  862. }
  863. </style>
  864. </head>
  865. <body>
  866. <?php
  867. // Main menu
  868. $food_menu = file("food.txt", FILE_IGNORE_NEW_LINES);
  869. $menu_mon = explode(":!:", $food_menu[0]);
  870. $menu_tue = explode(":!:", $food_menu[1]);
  871. $menu_wed = explode(":!:", $food_menu[2]);
  872. $menu_thu = explode(":!:", $food_menu[3]);
  873. $menu_fri = explode(":!:", $food_menu[0]);
  874. ?>
  875. <form method="POST" action="update_menu.php">
  876. <table>
  877. <tr>
  878. <td>
  879. <input type="submit" value="Monday" name="mon" class="button">
  880. </td>
  881. <td>
  882. <p name="starter">
  883. <?php
  884. echo $menu_mon[1];
  885.  
  886. ?>
  887. </p>
  888. ---
  889. <p name="main">
  890. <?php
  891.  
  892. echo $menu_mon[2];
  893.  
  894. >
  895. </p>
  896. ---
  897. <p name="des">
  898. <?php
  899.  
  900. echo $menu_mon[3];
  901. ?>
  902. </p>
  903. </td>
  904. </tr>
  905. <tr>
  906. <td>
  907. <input type="submit" value="Tuesday" name="tue" class="button">
  908. </td>
  909. <td>
  910. <p name="starter">
  911. <?php
  912. echo $menu_tue[1];
  913. ?>
  914. </p>
  915. ---
  916. <p name="main">
  917. <?php
  918. echo $menu_tue[2];
  919.  
  920. ?>
  921. </p>
  922. ---
  923. <p name="des">
  924. <?php
  925. echo $menu_tue[3];
  926. ?>
  927. </p>
  928. </td>
  929. </tr>
  930. <tr>
  931. <td>
  932. <input type="submit" value="Wednesday" name="wed" class="button">
  933. </td>
  934. <td>
  935. <p name="starter">
  936. <?php
  937. echo $menu_wed[1];
  938. ?>
  939. </p>
  940. ---
  941. <p name="main">
  942. <?php
  943. echo $menu_wed[2];
  944. ?>
  945. </p>
  946. ---
  947. <p name="des">
  948. <?php
  949. echo $menu_wed[3];
  950. ?>
  951. </p>
  952. </td>
  953. </tr>
  954. <tr>
  955. <td>
  956. <input type="submit" value="Thursday" name="thu" class="button">
  957. </td>
  958. <td>
  959. <p name="starter">
  960. <?php
  961. echo $menu_thu[1];
  962. ?>
  963. </p>
  964. ---
  965. <p name="main">
  966. <?php
  967. echo $menu_thu[2];
  968. ?>
  969. </p>
  970. ---
  971. <p name="des">
  972. <?php
  973. echo $menu_thu[3];
  974. ?>
  975. </p>
  976. </td>
  977. </tr>
  978. <tr>
  979. <td>
  980. <input type="submit" value="Friday" name="fri" class="button">
  981. </td>
  982. <td>
  983. <p name="starter">
  984. <?php
  985. echo $menu_fri[1];
  986. ?>
  987. </p>
  988. ---
  989. <p name="main">
  990. <?php
  991. echo $menu_fri[2];
  992. ?>
  993. </p>
  994. ---
  995. <p name="des">
  996. <?php
  997. echo $menu_fri[3];
  998. ?>
  999. </p>
  1000. </td>
  1001. </tr>
  1002. </table>
  1003. </form>
  1004. </body>
  1005. </html>
  1006. Update_form.php
  1007. <html>
  1008. <body>
  1009. <?php
  1010. //Using isset()
  1011. settype($day, "integer");
  1012.  
  1013. if(isset($_POST["mon"])){
  1014. $day = 0;
  1015. }
  1016. elseif(isset($_POST["tue"])){
  1017. $day = 1;
  1018. }
  1019. elseif(isset($_POST["wed"])){
  1020. $day = 2;
  1021. }
  1022. elseif(isset($_POST["thu"])){
  1023. $day = 3;
  1024. }
  1025. elseif(isset($_POST["fri"])){
  1026. $day = 4;
  1027. }
  1028. // echo $day;
  1029.  
  1030.  
  1031.  
  1032. // Main menu
  1033. $food_menu = file("food.txt", FILE_IGNORE_NEW_LINES);
  1034. $menu_day_selected = explode(":!:", $food_menu[$day]);
  1035. //echo $menu_day_selected[1];
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041. ?>
  1042. <form method="post" action="update_food.php">
  1043. <table>
  1044. <tr>
  1045. <td>
  1046. Day:
  1047. </td>
  1048. <td>
  1049. <input type="text" name="day" value="<?php echo
  1050. $menu_day_selected[0];?>" readonly><br>
  1051. </td>
  1052. </tr>
  1053. <tr>
  1054. <td>
  1055. Starter:
  1056. </td>
  1057. <td>
  1058. <input type="text" name="starter" value="<?php echo
  1059. $menu_day_selected[1];?>"><br>
  1060. </td>
  1061. </tr>
  1062. <tr>
  1063. <td>
  1064. Main Course:
  1065. </td>
  1066. <td>
  1067. <input type="text" name="main_course" value="<?php echo
  1068. $menu_day_selected[2];?>"><br>
  1069. </td>
  1070. </tr>
  1071. <tr>
  1072. <td>
  1073. Dessert:
  1074. </td>
  1075. <td>
  1076. <input type="text" name="des" value="<?php echo
  1077. $menu_day_selected[3];?>"><br>
  1078. </td>
  1079. </tr>
  1080. <tr>
  1081. <td colspan="2" style="text-align:center;">
  1082. <input type="submit" value="Update" name="update_txt">
  1083. </td>
  1084. </tr>
  1085. <tr>
  1086. <td>
  1087. <a href="lab.php">Back to menu</a>
  1088. </td>
  1089. </tr>
  1090. </table>
  1091. </form>
  1092. </body>
  1093. </html>
  1094. Update.php
  1095. <?php
  1096. $food_menu = file("food.txt", FILE_IGNORE_NEW_LINES);
  1097. // print_r ($food_menu);
  1098. //$current_day = "";
  1099.  
  1100. if(isset($_POST['day'])){
  1101. $current_day = $_POST['day'];
  1102. switch($current_day){
  1103. case 'MONDAY':
  1104. $menu_day = 0;
  1105. break;
  1106. case 'TUESDAY':
  1107. $menu_day = 1;
  1108. break;
  1109. case 'WEDNESDAY':
  1110. $menu_day = 2;
  1111. break;
  1112. case 'THURSDAY':
  1113. $menu_day = 3;
  1114. break;
  1115. case 'FRIDAY':
  1116. $menu_day = 4;
  1117. break;
  1118. }
  1119.  
  1120. $menu_day_exploded = explode(":!:",$food_menu[$menu_day]);
  1121. // echo $menu_day_exploded[0];
  1122.  
  1123. $starter = $_POST['starter'];
  1124. $main_course = $_POST['main_course'];
  1125. $des = $_POST['des'];
  1126.  
  1127. // echo $des;
  1128.  
  1129. //replacing the array vals
  1130.  
  1131. // echo $menu_day_exploaded[0];
  1132. $menu_day_exploaded[0] = $current_day;
  1133. $menu_day_exploaded[1] = $starter;
  1134. $menu_day_exploaded[2] = $main_course;
  1135. $menu_day_exploaded[2] = $des;
  1136.  
  1137. // print_r($menu_day_exploaded);
  1138. $final = $menu_day_exploaded;
  1139. // print_r($final);
  1140. // echo $menu_day_exploaded[3];
  1141.  
  1142.  
  1143. $imploded_vals = implode(":!:", $final);
  1144. $food_menu[$menu_day] = $imploded_vals;
  1145.  
  1146. // echo $food_menu;
  1147. // echo $food_menu[$menu_day];
  1148. // print_r($food_menu);
  1149.  
  1150. // $fp = fopen('file.txt', 'w');
  1151. // fwrite($fp, print_r($food_menu, TRUE));
  1152. // fclose($fp);
  1153. file_put_contents('food.txt', implode(PHP_EOL, $food_menu));
  1154. echo '<script>window.location.href = "lab.php";</script>';
  1155.  
  1156. }
  1157. ?>
  1158. Output 1: using readonly for day input
  1159. Icecream to Gulab Jamun
  1160. Update in the main menu.
  1161. Output 2: without using readonly for day input
  1162. TUESDAY CHANGED TO THURSDAY
  1163. Now Thursday and Tuesday both have same menu
  1164. EXPERIMENT NO 6
  1165. 16BCE0281
  1166. BELAL AHMED
  1167. Question :
  1168. a) Write a query that lists the names of the movies whose title contains the word “space”
  1169. in descending order by rank.
  1170. CODE:
  1171. <html>
  1172. <body>
  1173. <head>
  1174. <title>
  1175. 16BCE0281
  1176. </title>
  1177. <style>
  1178. .table{
  1179. align:center;
  1180. padding:5px;
  1181. margin-top:500px,
  1182. border-spacing: 10px;
  1183. font-size:44;
  1184. }
  1185. </style>
  1186. </head>
  1187. <body>
  1188. <div align="center">
  1189. <table border="1" class="table">
  1190. <tr>
  1191. <th>Id</th>
  1192. <th>Name</th>
  1193. <th>Year</th>
  1194. <th>Rank</th>
  1195. </tr>
  1196. <?php
  1197. $servername = "localhost";
  1198. $username = "";
  1199. $password = "";
  1200. // Create connection
  1201. $conn = mysqli_connect($servername, $username, $password,"test");
  1202. $sql = "select * from movies where movies.name like '%Space%' order by movies.rank
  1203. desc;";
  1204. $result = $conn->query($sql);
  1205. while($row = $result->fetch_assoc()) {
  1206. echo "<tr>";
  1207. echo "<td>" . $row['id'] ."</td>";
  1208. echo "<td>" . $row['name'] . "</td>";
  1209. echo "<td>" . $row['movies'] . "</td>";
  1210. echo "<td>" . $row['rank'] . "</td>";
  1211. echo "</tr>";
  1212. }
  1213. $conn->close();
  1214. ?>
  1215. </table>
  1216. </div>
  1217. </body>
  1218. </html>
  1219. OUTTPUT:
  1220. b) Write a query that lists the female actors who appeared in a movie during the 90s (1990-
  1221. 1999) that was rated higher than 8.5.
  1222. Code:
  1223. <html>
  1224. <body>
  1225. <head>
  1226. <title>
  1227. 16BCE0281
  1228. </title>
  1229. <style>
  1230. .table{
  1231. align:center;
  1232. padding:5px;
  1233. margin-top:500px,
  1234. border-spacing: 10px;
  1235. font-size:44;
  1236. }
  1237. </style>
  1238. </head>
  1239. <body>
  1240. <h1 align="center"BELAL AHMED</h1>
  1241. <br/>
  1242. <div align="center">
  1243. <table border="1" class="table">
  1244. <tr>
  1245. <th>First Name</th>
  1246. <th>Last Name</th>
  1247. </tr>
  1248. <?php
  1249. $servername = "localhost";
  1250. $username = "root";
  1251. $password = "1234";
  1252. // Create connection
  1253. $conn = mysqli_connect($servername, $username, $password,"test");
  1254. $sql = "select actors.first_name,actors.last_name from((actors inner join roles on
  1255. actors.id=roles.actor_id) inner join movies on roles.movie_id=movies.id) where
  1256. actors.gender='F' and movies.movies between 1990 and 1995 and movies.rank>8.5";
  1257. $result = $conn->query($sql);
  1258. while($row = $result->fetch_assoc()) {
  1259. echo "<tr>";
  1260. echo "<td>" . $row['first_name'] ."</td>";
  1261. echo "<td>" . $row['last_name'] . "</td>";
  1262. echo "</tr>";
  1263. }
  1264. $conn->close();
  1265. ?>
  1266. </table>
  1267. </div>
  1268. </body>
  1269. </html>
  1270. OUTTPUT:
  1271. c) Write a query that lists all actors who was in a movie rated lower than 3.0 two or more
  1272. times. List the name of the actor, the movie and each rating, ordered ascending by the actors’
  1273. last name then first name.
  1274. Code:
  1275. <html>
  1276. <body>
  1277. <head>
  1278. <title>
  1279. 16BCE0281
  1280. </title>
  1281. <style>
  1282. .table{
  1283. align:center;
  1284. padding:5px;
  1285. margin-top:500px,
  1286. border-spacing: 10px;
  1287. font-size:44;
  1288. }
  1289. </style>
  1290. </head>
  1291. <body>
  1292. <h1 align="center" BELAL AHMED</h1>
  1293. <br/>
  1294. <h1 align="center">Question c.</h1>
  1295. <div align="center">
  1296. <table border="1" class="table">
  1297. <tr>
  1298. <th>Actor First Name</th>
  1299. <th>Actor Last Name</th>
  1300. <th>Movie Name</th>
  1301. <th>Rank</th>
  1302. </tr>
  1303. <?php
  1304. $servername = "localhost";
  1305. $username = "";
  1306. $password = "";
  1307. // Create connection
  1308. $conn = mysqli_connect($servername, $username, $password,"test");
  1309. $sql = "select actors.first_name,actors.last_name,movies.name,movies.rank from(((actors
  1310. inner join roles on actors.id=roles.actor_id)inner join movies on roles.movie_id
  1311. =movies.id)inner join movie_genres on movies.id=movie_genres.movie_id) where (select
  1312. count(*) from movies where movies.rank<3)>=2 order by actors.first_name asc;
  1313. ";
  1314. $result = $conn->query($sql);
  1315. if ($result->num_rows > 0) {
  1316. while($row = $result->fetch_assoc()) {
  1317. echo "<tr>";
  1318. echo "<td>" . $row['first_name'] ."</td>";
  1319. echo "<td>" . $row['last_name'] . "</td>";
  1320. echo "<td>" . $row['name'] . "</td>";
  1321. echo "<td>" . $row['rank'] . "</td>";
  1322. echo "</tr>";
  1323. }
  1324. }
  1325. else
  1326. echo " <h1>0 results</h1> ";
  1327. $conn->close();
  1328. ?>
  1329. </table>
  1330. </div>
  1331. </body>
  1332. </html>
  1333. OUTTPUT:
  1334. d) Write a query that lists all actors who have been in two or more movies of different genres.
  1335. List their name, movie and their respective genres.
  1336. Code:
  1337. <html>
  1338. <body>
  1339. <head>
  1340. <title>
  1341. 16BCE0281
  1342. </title>
  1343. <style>
  1344. .table{
  1345. align:center;
  1346. padding:5px;
  1347. margin-top:500px,
  1348. border-spacing: 10px;
  1349. font-size:44;
  1350. }
  1351. </style>
  1352. </head>
  1353. <body>
  1354. <h1 align="center"> Belal AHMED</h1>
  1355. <br/>
  1356. <h1 align="center">Question d.</h1>
  1357. <div align="center">
  1358. <table border="1" class="table">
  1359. <tr>
  1360. <th>ID</th>
  1361. <th>Movie Name</th>
  1362. <th>Year</th>
  1363. <th>Rank</th>
  1364. </tr>
  1365. <?php
  1366. $servername = "localhost";
  1367. $username = "";
  1368. $password = "";
  1369. // Create connection
  1370. $conn = mysqli_connect($servername, $username, $password,"test");
  1371. $sql = "select * from movies where(select count(actors.id) from(((actors inner join roles on
  1372. actors.id=roles.actor_id)inner join movie_genres on
  1373. roles.movie_id=movie_genres.movie_id)inner join movies on
  1374. movies.id=roles.movie_id))>=2; ";
  1375. $result = $conn->query($sql);
  1376. if ($result->num_rows > 0) {
  1377. while($row = $result->fetch_assoc()) {
  1378. echo "<tr>";
  1379. echo "<td>" . $row['id'] ."</td>";
  1380. echo "<td>" . $row['name'] . "</td>";
  1381. echo "<td>" . $row['movies'] . "</td>";
  1382. echo "<td>" . $row['rank'] . "</td>";
  1383. echo "</tr>";
  1384. }
  1385. }
  1386. else
  1387. echo " <h1>0 results</h1> ";
  1388. $conn->close();
  1389. ?>
  1390. </table>
  1391. </div>
  1392. </body>
  1393. </html>
  1394. OUTPUT:
  1395. e) Write update query -update “action” genres into “horror” and display no.of rows affected.
  1396. Code:
  1397. <html>
  1398. <body>
  1399. <head>
  1400. <title>
  1401. 16BCE0281
  1402. </title>
  1403. <style>
  1404. .table{
  1405. align:center;
  1406. padding:5px;
  1407. margin-top:500px,
  1408. border-spacing: 10px;
  1409. font-size:44;
  1410. }
  1411. </style>
  1412. </head>
  1413. <body>
  1414. <h1 align="center"> BELAL AHMED</h1>
  1415. <br/>
  1416. <h1 align="center">Question e.</h1>
  1417. <div align="center">
  1418. <table border="1" class="table">
  1419. <tr>
  1420. <th>Movie ID</th>
  1421. <th>Genre</th>
  1422. </tr>
  1423. <?php
  1424. $servername = "localhost";
  1425. $username = "";
  1426. $password = "";
  1427. // Create connection
  1428. $conn = mysqli_connect($servername, $username, $password,"test");
  1429. $sql1 = "update movie_genres set genre='action' where genre='horror'";
  1430. $conn->query($sql1);
  1431. $sql = "select * from movie_genres";
  1432. $result = $conn->query($sql);
  1433. if ($result->num_rows > 0) {
  1434. while($row = $result->fetch_assoc()) {
  1435. echo "<tr>";
  1436. echo "<td>" . $row['movie_id'] ."</td>";
  1437. echo "<td>" . $row['genre'] . "</td>";
  1438. echo "</tr>";
  1439. }
  1440. }
  1441. else
  1442. echo " <h1>0 results</h1> ";
  1443. $conn->close();
  1444. ?>
  1445. </table>
  1446. </div>
  1447. </body>
  1448. </html>
  1449. OUTTPUT:
  1450. BEFORE UPDATE:
  1451. AFTER UPDATE:
  1452. EXPERIMENT NO 7
  1453. 16BCE0281
  1454. BELAL AHMED
  1455. Q1.
  1456. CODE:
  1457. import java.util.Scanner ;
  1458. import java.io.*;//import java.lang.*;
  1459. public class bilal implements CharSequence {
  1460. private String s;
  1461. public bilal(String s) {
  1462. //It would be much more efficient to just reverse the string
  1463. //in the constructor. But a lot less fun!
  1464. this.s = s;
  1465. }
  1466. //If the string is backwards, the end is the beginning!
  1467. private int fromEnd(int i) {
  1468. return s.length() - 1 - i;
  1469. }
  1470. public char charAt(int i) {
  1471. if ((i < 0) || (i >= s.length())) {
  1472. throw new StringIndexOutOfBoundsException(i);
  1473. }
  1474. return s.charAt(fromEnd(i));
  1475. }
  1476. public int length() {
  1477. return s.length();
  1478. }
  1479. public CharSequence subSequence(int start, int end) {
  1480. if (start < 0) {
  1481. throw new StringIndexOutOfBoundsException(start);
  1482. }
  1483. if (end > s.length()) {
  1484. throw new StringIndexOutOfBoundsException(end);
  1485. }
  1486. if (start > end) {
  1487. throw new StringIndexOutOfBoundsException(start - end);
  1488. }
  1489. StringBuilder sub =
  1490. new StringBuilder(s.subSequence(fromEnd(end), fromEnd(start-1)));
  1491. System.out.println("Using subsequence string function ");
  1492. return sub.reverse();
  1493. }
  1494. public String toString() {
  1495. StringBuilder s = new StringBuilder(this.s);
  1496. System.out.println("Using toString Function function \n");
  1497. return s.reverse().toString();
  1498. }
  1499. public static void main(String[] args) {
  1500. String st;
  1501. System.out.println("Code written by BELAL AHMED 16BCE0281");
  1502. System.out.println("Enter the string to be reversed");
  1503. Scanner keyboard = new Scanner( System.in ) ;
  1504. st = keyboard.nextLine();
  1505. bilal s = new bilal(st);
  1506. //exercise charAt() and length()
  1507. for (int i = 0; i < s.length(); i++) {
  1508. System.out.print(s.charAt(i));
  1509. }
  1510.  
  1511. System.out.println("");
  1512. //exercise subSequence() and length();
  1513. // h
  1514. System.out.println(s.subSequence(0,st.length()-1));
  1515. }
  1516. }
  1517. OUTPUT:
  1518. Q2.
  1519. CODE:
  1520. import java.time.* ; // for classes LocalDate, Period
  1521. import java.time.temporal.WeekFields ;
  1522. import java.util.Scanner ;
  1523. class EnglishCalendar
  1524. {
  1525. protected int this_year ;
  1526. protected int this_month ;
  1527. protected String[] names_of_months ;
  1528. protected String week_description ;
  1529. public EnglishCalendar()
  1530. {
  1531. }
  1532. public EnglishCalendar( int given_year, int given_month )
  1533. {
  1534. String[] english_names_of_months ={ "January", "February", "March", "April","May",
  1535. "June", "July", "August","September", "October", "November", "December" } ;
  1536. String english_week_description = " Week Mon Tue Wed Thu Fri Sat Sun" ;
  1537. names_of_months = english_names_of_months ;
  1538. week_description = english_week_description ;
  1539. this_year = given_year ;
  1540. this_month = given_month ;
  1541. }
  1542. public int get_calendar_year()
  1543. {
  1544. return this_year ;
  1545. }
  1546. public int get_calendar_month()
  1547. {
  1548. return this_month ;
  1549. }
  1550. public void increment_calendar_month()
  1551. {
  1552. this_month ++ ;
  1553. if ( this_month > 12 )
  1554. {
  1555. this_month = 1 ;
  1556. this_year ++ ;
  1557. }
  1558. }
  1559. public void decrement_calendar_month()
  1560. {
  1561. this_month -- ;
  1562. if ( this_month < 1 )
  1563. {
  1564. this_month = 12 ;
  1565. this_year -- ;
  1566. }
  1567. }
  1568. public void first_month()
  1569. {
  1570. this_month=1;
  1571. this_year++;
  1572. }
  1573. public void print()
  1574. {
  1575. LocalDate a_day_in_this_month = LocalDate.of( this_year, this_month, 1 ) ;
  1576. // Days of week are numbered from 1 to 7.
  1577. // The first day of week is Monday.
  1578. int day_of_week_value = 1 ;
  1579. int day_of_week_of_first_day = a_day_in_this_month.getDayOfWeek().getValue() ;
  1580. System.out.print("\n\n " + names_of_months[ this_month - 1 ]+ " " + this_year + "\n\n" +
  1581. week_description + "\n\n");
  1582. System.out.printf( "%4d ",
  1583. a_day_in_this_month.get(WeekFields.ISO.weekOfWeekBasedYear()) ) ;
  1584. // The first week of a month is often an incomplete week,
  1585. // i.e., the first part of week belongs to the previous
  1586. // month. In place of the days that belong to the previous
  1587. // month we print just spaces.
  1588. while ( day_of_week_value != day_of_week_of_first_day )
  1589. {
  1590. System.out.print( " " ) ;
  1591. day_of_week_value ++ ;
  1592. }
  1593. while ( this_month == a_day_in_this_month.getMonthValue() )
  1594. {
  1595. if ( day_of_week_value >= 8 )
  1596. {
  1597. System.out.printf( "\n%4d
  1598. ",a_day_in_this_month.get(WeekFields.ISO.weekOfWeekBasedYear()) ) ;
  1599. day_of_week_value = 1 ;
  1600. }
  1601. System.out.printf( "%5d", a_day_in_this_month.getDayOfMonth() ) ;
  1602. a_day_in_this_month = a_day_in_this_month.plusDays( 1 ) ;
  1603. day_of_week_value ++ ;
  1604. }
  1605. System.out.print( "\n" ) ;
  1606. }
  1607. }
  1608. class SpanishCalendar extends EnglishCalendar
  1609. {
  1610. public SpanishCalendar( int given_year, int given_month )
  1611. {
  1612. String[] spanish_names_of_months ={ "Enero", "Febrero", "Marzo", "Abril","Mayo",
  1613. "Junio", "Julio", "Agosto","Septiembre", "Octubre", "Noviembre", "Diciembre" } ;
  1614. String spanish_week_description ="Semana Lun Mar Mie Jue Vie Sab Dom" ;
  1615. names_of_months = spanish_names_of_months ;
  1616. week_description = spanish_week_description ;
  1617. this_year = given_year ;
  1618. this_month = given_month ;
  1619. }
  1620. }
  1621. public class MonthCalendars
  1622. {
  1623. public static void main( String[] not_in_use )
  1624. {
  1625. Scanner keyboard = new Scanner( System.in ) ;
  1626. SpanishCalendar a_spanish_calendar = new SpanishCalendar( 2015, 11 );
  1627. a_spanish_calendar.print() ;
  1628. EnglishCalendar calendar_to_print = new EnglishCalendar( 2015, 12 ) ;
  1629. calendar_to_print.print() ;
  1630. String user_selection = "????" ;
  1631. System.out.print("\n This program prints calendars. Please, selectfrom"+ "\n the following
  1632. menu by typing in a letter. ") ;
  1633. while ( user_selection.charAt( 0 ) != 'e' )
  1634. {
  1635. System.out.print("\n\n p Print previous calendar."+ "\n n Print next calendar."+ "\n s Switch
  1636. to Spanish calendars."+ "\n y Print next year's first month"+ "\n e Exit the program.\n\n " ) ;
  1637. user_selection = keyboard.nextLine() ;
  1638. if ( user_selection.charAt( 0 ) == 'p' )
  1639. {
  1640. calendar_to_print.decrement_calendar_month() ;
  1641. calendar_to_print.print() ;
  1642. }
  1643. if ( user_selection.charAt( 0 ) == 'y' )
  1644. {
  1645. calendar_to_print.first_month() ;
  1646. calendar_to_print.print() ;
  1647. }
  1648. else if ( user_selection.charAt( 0 ) == 'n' )
  1649. {
  1650. calendar_to_print.increment_calendar_month() ;
  1651. calendar_to_print.print() ;
  1652. }
  1653. else if ( user_selection.charAt( 0 ) == 's' )
  1654. {
  1655. // We'll take the calendar year and month from the old calendar
  1656. // object and use them to create a SpanishCalendar object.
  1657. calendar_to_print = new
  1658. SpanishCalendar(calendar_to_print.get_calendar_year(),calendar_to_print.get_calendar_mon
  1659. th() ) ;
  1660. calendar_to_print.print() ;
  1661. }
  1662. }
  1663. }
  1664. }
  1665. OUTPUT:
  1666. ON PRESSING “ p ” :
  1667. ON PRESSING “ n ” :
  1668. ON PRESSING “ s ” :
  1669. ON PRESSING “ y ” :
  1670. EXPERIMENT NO 8
  1671. 16BCE0281
  1672. BELAL AHMED
  1673. 1. Write a Java Program to implement the bank operation using Multiple Inheritance
  1674. (Bank Interface,
  1675. Customer & Account classes).
  1676. a) Crete a Interface Bank having data members like rate of interest, no_of_years and
  1677. use method
  1678. show( )
  1679. b) Crete a class Customer with the data members customer_name, customer_id and
  1680. method
  1681. display( )
  1682. c) Create another class Account having data members account_no, account_balance
  1683. and method
  1684. interest( ) which Extends the Customer class and implemented Bank interface
  1685. d) Write the tester class with the name Account details. Pass the Custome Name,
  1686. ID,Account
  1687. Numner and Balance through main method. Display the Rate of interest for 3 years @
  1688. 12% and
  1689. display the output as given below.
  1690. Customer Name = XYZ
  1691. Customer Id = 12345678
  1692. Account No. = 9876543
  1693. Account Balance = 5000.0
  1694. Interest = 1800.0
  1695. CODE:
  1696. interface Bank
  1697. {
  1698. float rate = 12.0f;
  1699. int no_of_years=3;
  1700. void show();
  1701. }
  1702. class Customer
  1703. {
  1704. String cust_name;
  1705. int cust_id;
  1706. Customer(String n, int i)
  1707. {
  1708. cust_name = n;
  1709. cust_id = i;
  1710. }
  1711. void display()
  1712. {
  1713. System.out.println("Customer Name = "+cust_name); System.out.println("Customer Id =
  1714. "+cust_id);
  1715. }
  1716. }
  1717. class Account extends Customer implements Bank
  1718. {
  1719. int acc_no;
  1720. float acc_bal;
  1721. Account(String n, int b, int x, float y)
  1722. {
  1723. super(n, b);
  1724. acc_no=x;
  1725. acc_bal=y;}
  1726. public void show()
  1727. {
  1728. display();
  1729. System.out.println("Account No. = "+acc_no); System.out.println("Account Balance =
  1730. "+acc_bal);
  1731. }
  1732. void interest()
  1733. {
  1734. show();
  1735. float intr = (rate*acc_bal*no_of_years)/100;
  1736. System.out.println("Interest = "+intr);
  1737. }
  1738. }
  1739. public class Acc
  1740. {
  1741. public static void main (String[] args)
  1742. {
  1743. Account ac = new Account("Nimesh Poddar", 12345678, 9876543, 10000); ac.interest();
  1744. }
  1745. }
  1746. OUTPUT:
  1747. QUESTION 2:
  1748. Write a java program to create interface named taxcalculation. Use methods like
  1749. information ( ), show ( ) and also maintain the Tax rate as 20%. Implement this
  1750. interface in employee class to calculate the tax of the employee based on the number of
  1751. days worked in the company.Get the input from the user for the Salary (per/day) and
  1752. No. of days worked.
  1753. CODE:
  1754. import java.io.*;
  1755. import java.lang.System;
  1756. interface taxcalc
  1757. {
  1758. public void info();
  1759. public void show();
  1760. public final double tax=20;
  1761. }
  1762. class employee implements taxcalc
  1763. {
  1764. int salary;
  1765. double no_days;
  1766. employee(int a, double b)
  1767. {
  1768. salary=a;
  1769. no_days=b;
  1770. }
  1771. public void info()
  1772. {
  1773. double rate;
  1774. java.util.Date date=new java.util.Date();
  1775. rate=((salary*no_days)/tax);
  1776. System.out.println("Tax calculated as :"+"("+date+")"+rate);
  1777. }
  1778. public void show()
  1779. {
  1780. System.out.println("thank you for using tax app.");
  1781. }
  1782. }
  1783. public class office
  1784. {
  1785. public static void main(String[] args) throws IOException
  1786. {
  1787. BufferedReader b;
  1788. b=new BufferedReader(new InputStreamReader(System.in));
  1789. System.out.println("Enter the salary:");
  1790. int sal=Integer.parseInt(b.readLine());
  1791. System.out.println("Enter the number of days worked:");
  1792. double nod=Double.parseDouble(b.readLine());
  1793. employee obj=new employee(sal, nod); obj.info();
  1794. obj.show();
  1795. }
  1796. }
  1797. OUTPUT:
  1798. QUESTION 3:
  1799. Create a package named VITRational. It should have a class YYRational (YY is your
  1800. initial). The class should have method to simplify the rational number. The input
  1801. received from the user is of the form a/b as string and it is passed as argument to the
  1802. method Simplify(string). This method has to display the simplified output.(eg:simplify(
  1803. 15/20) - >output:3/4). Write a java application program which make use of the above
  1804. method.
  1805. CODE:
  1806. package VITrational;
  1807. import java.lang.*;
  1808. public class NPrational
  1809. {
  1810. int num, den, i, small;
  1811. String n, d, ans;
  1812. String spl[]=new String[2];
  1813. public NPrational()
  1814. {
  1815. num=0;
  1816. den=0;
  1817. }
  1818. public void simplify(String a)
  1819. {
  1820. spl=a.split("/");
  1821. num=Integer.parseInt(spl[0]);
  1822. den=Integer.parseInt(spl[1]);
  1823. small=((num<den)?num:den);
  1824. for(i=num;i>=1;i--)
  1825. {
  1826. if(num%i==0 && den%i==0)
  1827. {
  1828. num/=i;
  1829. den/=i;
  1830. }
  1831. }
  1832. n=Integer.toString(num);
  1833. d=Integer.toString(den);
  1834. ans=n.concat("/");
  1835. ans=ans.concat(d);
  1836. System.out.println("Simplified answer is : "+ans);
  1837. }
  1838. }
  1839. import VITrational.*;
  1840. import java.io.*;
  1841. import java.util.*;
  1842. class rat
  1843. {
  1844. public static void main(String args[])
  1845. {
  1846. String a;
  1847. NPrational r=new NPrational(); Scanner s=new Scanner(System.in);
  1848. System.out.println("Enter rational number (a/b) : ");
  1849. a=s.next();
  1850. r.simplify(a);
  1851. }
  1852. }
  1853. OUTPUT:
  1854. 4. Develop an Java application using hierarchy concept that accepts several types of
  1855. orders: store orders,
  1856. warehouse orders, and online orders. The following requirements have to be
  1857. implemented:
  1858. a. All orders share some common properties like order ID, a list of products, date/time
  1859. created, and amount.
  1860. b. Some types of orders may contain their own specific properties (store ID, store
  1861. representative for store orders,warehouse ID for warehouse order and coupoun code
  1862. for online order)
  1863. c. Business logic for ordervalidation and processing varies by type, Order cancellation
  1864. logic is universal across all types.
  1865. CODE:
  1866. import java.io.*;
  1867. import java.lang.*;
  1868. public interface Order
  1869. {
  1870. public int orderId=1;
  1871. public String date="23.10.2018";//Date/time creation of the product
  1872. public double amount=8.0;
  1873. }
  1874. import java.io.*;
  1875. import java.lang.*;
  1876. public class WarehouseOrder implements Order
  1877. {
  1878. public int warehouseId;
  1879. public void WarehouseOrder()
  1880. {
  1881. warehouseId=0;
  1882. }
  1883. public void displayOrder()
  1884. {
  1885. System.out.println("Your order id is "+orderId);
  1886. System.out.println("Your order date is "+date);
  1887. System.out.println("Your total amount is "+amount);
  1888. System.out.println("Your warehouse ID is"+warehouseId);
  1889. }
  1890. public static void main(String args[])throws IOException
  1891. {
  1892. WarehouseOrder obj = new WarehouseOrder();
  1893. obj.WarehouseOrder();
  1894. obj.displayOrder();
  1895. }
  1896. }
  1897. import java.io.*;
  1898. import java.lang.*;
  1899. public class StoreOrder implements Order
  1900. {
  1901. public int storeId;
  1902. public String representative;
  1903. public void StoreOrder()
  1904. {
  1905. storeId=927;
  1906. representative="Hello";
  1907. }
  1908. public void displayOrder()
  1909. {
  1910. System.out.println("Your order id is "+orderId);
  1911. System.out.println("Your order date is "+date);
  1912. System.out.println("Your total amount is "+amount);
  1913. System.out.println("Your store representative is"+representative);
  1914. }
  1915. public static void main(String args[])throws IOException
  1916. {
  1917. StoreOrder obj = new StoreOrder();
  1918. obj.StoreOrder();
  1919. obj.displayOrder();
  1920. }
  1921. }
  1922. import java.io.*;
  1923. import java.lang.*;
  1924. public class OnlineOrder implements Order
  1925. {
  1926. public String couponcode;
  1927. public void OnlineOrder()
  1928. {
  1929. couponcode="Nun";
  1930. }
  1931. public void displayOrder()
  1932. { System.out.println("Your order id is "+orderId);
  1933. System.out.println("Your order date is "+date);
  1934. System.out.println("Your total amount is "+amount);
  1935. System.out.println("Your coupon code is "+couponcode);
  1936. }
  1937. public static void main(String args[])throws IOException
  1938. { OnlineOrder obj = new OnlineOrder();
  1939. obj.OnlineOrder();
  1940. obj.displayOrder();
  1941. }
  1942. }
  1943. OUTPUT:
  1944. EXPERIMENT NO 9
  1945. 16BCE0281
  1946. BELAL AHMED
  1947. CODE:
  1948. index.jsp
  1949. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  1950. <!DOCTYPE html>
  1951. <html>
  1952. <head>
  1953. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  1954. <title>Shopping Cart - Login</title>
  1955. <style type="text/css">
  1956. <!--
  1957. .container {
  1958. height: 700px;
  1959. width: 900px;
  1960. margin:auto;
  1961. }
  1962. .headbanner {
  1963. float: left;
  1964. height: 80px;
  1965. width: 900px;
  1966. vertical-align:middle;
  1967. background-color:#FFCC00;
  1968. }
  1969. .container .headbanner h1 {
  1970. font-family: Verdana, Geneva, sans-serif;
  1971. color: #CC3300;
  1972. }
  1973. .mycontent {
  1974. float: left;
  1975. height: 500px;
  1976. width: 900px;
  1977. }
  1978. .myfooter {
  1979. float: left;
  1980. height: 100px;
  1981. width: 900px;
  1982. border-top-width:3px;
  1983. border-top-style:solid;
  1984. border-top-color:#FFCC00;
  1985. }
  1986. .container .myfooter h3 {
  1987. font-family: Verdana, Geneva, sans-serif;
  1988. font-size: 12px;
  1989. color:#CC3300;
  1990. }
  1991. .space {
  1992. float: left;
  1993. height: 35px;
  1994. width: 900px;
  1995. font-size: 24px;
  1996. font-family: Verdana, Geneva, sans-serif;
  1997. padding-top:15px;
  1998. }
  1999. .formcontent {
  2000. float: left;
  2001. height: 200px;
  2002. width: 900px;
  2003. }
  2004. .formtext {
  2005. color:#CC3300;
  2006. font-family:Verdana, Geneva, sans-serif;
  2007. }
  2008. -->
  2009. </style>
  2010. </head>
  2011. <body style="margin:0; padding:0">
  2012. <div class="container">
  2013. <div class="headbanner">
  2014. <h1 style="display:inline">
  2015. <center>
  2016. <img src="img/shopping.png" />[My Shopping Cart]
  2017. </center>
  2018. </h1>
  2019. </div>
  2020. <div class="mycontent">
  2021. <div class="space"><span><a class="formtext">Login</a></span></div>
  2022. <div class="formcontent">
  2023. <form action="loginval" method="post">
  2024. <table>
  2025. <tr>
  2026. <td class="formtext">Username :</td>
  2027. <td><input id="name" name="uname" type="text" size="30" /></td><td><a
  2028. style="font-size: 10px; font-family:lucida sans; color: darkgray">[Any name]</a></td>
  2029. </tr>
  2030. <tr>
  2031. <td class="formtext">Password :</td>
  2032. <td><input id="pas" name="pass" type="password" size="30" /></td><td><a
  2033. style="font-size: 10px; font-family:lucida sans; color: darkgray">[Pass = 1234]</a></td>
  2034. </tr>
  2035. <tr>
  2036. <td><input type="submit" value="Submit"/></td>
  2037. </tr>
  2038. </table>
  2039. </form>
  2040. </div>
  2041. </div>
  2042. <div class="myfooter">
  2043. <h3 style="font-weight:normal; padding-left:10px">&copy; BELAL AHMED </h3>
  2044. </div>
  2045. </div>
  2046. </body>
  2047. </html>
  2048. checkout.jsp
  2049. <%@page import="java.util.ArrayList"%>
  2050. <%@ page import="classes.item" %>
  2051. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2052. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2053. <html xmlns="http://www.w3.org/1999/xhtml">
  2054. <head>
  2055. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  2056. <title>Shopping Cart - Check out</title>
  2057. <style type="text/css">
  2058. <!--
  2059. .container {
  2060. height: 700px;
  2061. width: 900px;
  2062. margin:auto;
  2063. }
  2064. .headbanner {
  2065. float: left;
  2066. height: 80px;
  2067. width: 900px;
  2068. vertical-align:middle;
  2069. background-color:#FFCC00;
  2070. }
  2071. .container .headbanner h1 {
  2072. font-family: Verdana, Geneva, sans-serif;
  2073. color: #CC3300;
  2074. }
  2075. .mycontent {
  2076. float: left;
  2077. height: 500px;
  2078. width: 900px;
  2079. }
  2080. .myfooter {
  2081. float: left;
  2082. height: 100px;
  2083. width: 900px;
  2084. border-top-width:3px;
  2085. border-top-style:solid;
  2086. border-top-color:#FFCC00;
  2087. }
  2088. .container .myfooter h3 {
  2089. font-family: Verdana, Geneva, sans-serif;
  2090. font-size: 12px;
  2091. color:#CC3300;
  2092. }
  2093. td{
  2094. font-family:Verdana, Geneva, sans-serif;
  2095. font-weight:normal;
  2096. font-size:14px;
  2097. }
  2098. -->
  2099. </style>
  2100. </head>
  2101. <body style="margin:0; padding:0">
  2102. <form action="purchase" method="post">
  2103. <%
  2104. ArrayList it_list = (ArrayList) session.getAttribute("itemlist");
  2105. %>
  2106. <div class="container">
  2107. <div class="headbanner">
  2108. <h1 style="display:inline"><center>
  2109. <img src="img/shopping.png" />[My Shopping Cart]
  2110. </center></h1>
  2111. </div>
  2112. <div class="mycontent">
  2113. <a style="color:#CC3300; font-family:Verdana, Geneva, sans-serif; font-size:20px;
  2114. font-weight:bold">Checkout My Cart</a><br />
  2115. <table width="500px">
  2116. <%
  2117. for (int i = 0; i < it_list.size(); i++) {
  2118. classes.item itm = (item) it_list.get(i);
  2119. %>
  2120. <tr>
  2121. <td><%out.print(itm.name);%></td>
  2122. <td><%out.print(itm.price);%></td>
  2123. </tr>
  2124. <% }%>
  2125. <tr>
  2126. <td style="font-weight:bold">My Total</td><td style="fontweight:bold">$[<%out.print(session.getAttribute("total"));%>]</td>
  2127. </tr>
  2128. <tr>
  2129. <td><input type="submit" value="Purchase" /></td>
  2130. </tr>
  2131. <tr>
  2132. <td><img src="img/paywith.png" width="210" height="80" /></td></tr>
  2133. </table>
  2134. </div>
  2135. <div class="myfooter">
  2136. <h3 style="font-weight:normal; padding-left:10px">&copy; BELAL AHMED </h3>
  2137. </div>
  2138. </div>
  2139. </form>
  2140. </body>
  2141. </html>
  2142. success.jsp
  2143. <!DOCTYPE html>
  2144. <html>
  2145. <head>
  2146. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  2147. <title>Shopping Cart - Success</title>
  2148. <style type="text/css">
  2149. <!--
  2150. .container {
  2151. height: 700px;
  2152. width: 900px;
  2153. margin:auto;
  2154. }
  2155. .headbanner {
  2156. float: left;
  2157. height: 80px;
  2158. width: 900px;
  2159. vertical-align:middle;
  2160. background-color:#FFCC00;
  2161. }
  2162. .container .headbanner h1 {
  2163. font-family: Verdana, Geneva, sans-serif;
  2164. color: #CC3300;
  2165. }
  2166. .mycontent {
  2167. float: left;
  2168. height: 400px;
  2169. width: 900px;
  2170. padding-top:100px;
  2171. }
  2172. .myfooter {
  2173. float: left;
  2174. height: 100px;
  2175. width: 900px;
  2176. border-top-width:3px;
  2177. border-top-style:solid;
  2178. border-top-color:#FFCC00;
  2179. }
  2180. .container .myfooter h3 {
  2181. font-family: Verdana, Geneva, sans-serif;
  2182. font-size: 12px;
  2183. color:#CC3300;
  2184. }
  2185. .container .mycontent h3 {
  2186. font-family: Verdana, Geneva, sans-serif;
  2187. }
  2188. -->
  2189. </style>
  2190. </head>
  2191. <body style="margin:0; padding:0">
  2192. <%if(session.getAttribute("purch")!="true"){response.sendRedirect("index.jsp");
  2193. } %>
  2194.  
  2195. <form action="shop.jsp" method="post">
  2196. <div class="container">
  2197. <div class="headbanner">
  2198. <h1 style="display:inline"><center>
  2199. <img src="img/shopping.png" />[My Shopping Cart]
  2200. </center></h1>
  2201. </div>
  2202. <div class="mycontent">
  2203. <h3 align="center" style="color:#CC3300;">Purchase has been succeeded! Thank
  2204. You.<br /><input type="submit" value="Ok" /></h3>
  2205. </div>
  2206. <div class="myfooter">
  2207. <h3 style="font-weight:normal; padding-left:10px">&copy; BELAL AHMED</h3>
  2208. </div>
  2209. </div>
  2210. </form>
  2211. </body>
  2212. </html>
  2213. shop.jsp
  2214. <%@page import="java.util.ArrayList"%>
  2215. <%@ page import="classes.item" %>
  2216. <!DOCTYPE html>
  2217. <html>
  2218. <head>
  2219. <%
  2220. String user = (String) session.getAttribute("user");
  2221. if (user == null) {
  2222. response.sendRedirect("index.jsp");
  2223. }
  2224. %>
  2225. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  2226. <title>Shopping Cart - Shop</title>
  2227. <style type="text/css">
  2228. <!--
  2229. .container {
  2230. height: 850px;
  2231. width: 900px;
  2232. margin:auto;
  2233. }
  2234. .headbanner {
  2235. float: left;
  2236. height: 80px;
  2237. width: 900px;
  2238. vertical-align:middle;
  2239. background-color:#FFCC00;
  2240. }
  2241. .container .headbanner h1 {
  2242. font-family: Verdana, Geneva, sans-serif;
  2243. color: #CC3300;
  2244. }
  2245. .mycontent {
  2246. float: left;
  2247. height: 650px;
  2248. width: 900px;
  2249. }
  2250. .myfooter {
  2251. float: left;
  2252. height: 100px;
  2253. width: 900px;
  2254. border-top-width:3px;
  2255. border-top-style:solid;
  2256. border-top-color:#FFCC00;
  2257. }
  2258. .container .myfooter h3 {
  2259. font-family: Verdana, Geneva, sans-serif;
  2260. font-size: 12px;
  2261. color:#CC3300;
  2262. }
  2263. .cartof {
  2264. float: left;
  2265. height: 25px;
  2266. width: 900px;
  2267. font-family: Verdana, Geneva, sans-serif;
  2268. font-weight: bold;
  2269. padding-top:5px;
  2270. }
  2271. .cartcontent {
  2272. float: left;
  2273. height: 200px;
  2274. width: 900px;
  2275. background-color:#FFFFC2;
  2276. border-width:1px;
  2277. border-style:solid;
  2278. border-color:#FFCC00;
  2279. }
  2280. .prod1 {
  2281. float: left;
  2282. height: 100px;
  2283. width: 900px;
  2284. border-bottom-width:1px;
  2285. border-bottom-style:solid;
  2286. border-bottom-color:#FFCC00;
  2287. }
  2288. td{
  2289. padding-left:5px;
  2290. color:#900;
  2291. font-family:Verdana, Geneva, sans-serif;
  2292. }
  2293. .items {
  2294. float: left;
  2295. height: auto;
  2296. width: 900px;
  2297. }
  2298. tr.border_bottom td {
  2299. border-bottom-width:1px;
  2300. border-bottom-style:solid;
  2301. border-bottom-color:#FFCC00;
  2302. height:100px;
  2303. }
  2304. .myitems {
  2305. float: left;
  2306. height: 200px;
  2307. width: 600px;
  2308. border-right-width:1px;
  2309. border-right-style:solid;
  2310. border-right-color:#FFCC00;
  2311. overflow: auto;
  2312. }
  2313. th{
  2314. color:#FFF;
  2315. font-family:Verdana, Geneva, sans-serif;
  2316. font-weight:normal;
  2317. background-color:#900;
  2318. }
  2319. .total {
  2320. float: left;
  2321. height: 180px;
  2322. width: 285px;
  2323. font-family: Verdana, Geneva, sans-serif;
  2324. font-size: 24px;
  2325. font-weight: bold;
  2326. padding-top:20px;
  2327. padding-left:10px;
  2328. }
  2329. -->
  2330. </style>
  2331. </head>
  2332. <body style="margin:0; padding:0">
  2333. <div class="container">
  2334. <form action="requesthandle" method="post">
  2335. <div class="headbanner">
  2336. <h1 style="display:inline">
  2337. <center>
  2338. <img src="img/shopping.png" />[My Shopping Cart]
  2339. </center>
  2340. </h1>
  2341. </div>
  2342. <div class="mycontent">
  2343. <div class="cartof">
  2344. <center><a style="color: #CC3300;">Cart Of [<%
  2345. out.print(session.getAttribute("user"));%>]<input name="logout" type="submit"
  2346. value="Logout"></input></a></center>
  2347. </div>
  2348. <div class="cartcontent">
  2349. <div class="myitems">
  2350. <table width="600px" cellpadding="0" cellspacing="0">
  2351. <tr>
  2352. <th>#id</th>
  2353. <th>Item</th>
  2354. <th>Price</th>
  2355. <th>Action</th>
  2356. </tr>
  2357. <%if (session.getAttribute("itemlist") != null) {
  2358. ArrayList mycart = (ArrayList) session.getAttribute("itemlist");
  2359. for (int i = 0; i < mycart.size(); i++) {
  2360. item it = (item) mycart.get(i);
  2361. %>
  2362. <tr>
  2363. <td align="center"><%out.print(i);%></td>
  2364. <td align="center"><% out.print(it.name);%></td>
  2365. <td align="center"><% out.print(it.price);%></td>
  2366. <td align="center"><input name="del" type="submit" value="Delete"
  2367. onclick="this.value=<%out.print(i);%>"></input></td>
  2368. </tr>
  2369. <%}
  2370. }
  2371. %>
  2372. </table>
  2373. </div>
  2374. <div class="total">
  2375. <a>My Total : $[<% out.print(session.getAttribute("total"));%>]</a><br />
  2376. <a style="font-size:14px">Total Qty: [<% ArrayList il = (ArrayList)
  2377. session.getAttribute("itemlist");
  2378. out.print(il.size());%>]</a><br />
  2379. <input name="chkout" type="submit" value="Checkout" />
  2380. </div>
  2381. </div>
  2382. <div class="items">
  2383. <table width="900px">
  2384. <tr class="border_bottom">
  2385. <td>#1</td>
  2386. <td>Sunglass</td>
  2387. <td>Ray-Ban, Dark Purple Sunglass with the Casing</td>
  2388. <td>$34</td>
  2389. <td><img src="img/sunglass.jpg" width="90" height="90" /></td>
  2390. <td><input name="addtocart1" type="submit" value="Add to Cart" /></td>
  2391. </tr>
  2392. <tr class="border_bottom">
  2393. <td>#2</td>
  2394. <td>Wrist Watch</td>
  2395. <td>Quartz, Men's wrist watch, Black</td>
  2396. <td>$66</td>
  2397. <td><img src="img/watch.jpg" width="90" height="90" /></td>
  2398. <td><input name="addtocart2" type="submit" value="Add to Cart" /></td>
  2399. </tr>
  2400. <tr class="border_bottom">
  2401. <td>#3</td>
  2402. <td>Camera</td>
  2403. <td>Lumix, 16x Digital Camera</td>
  2404. <td>$167</td>
  2405. <td><img src="img/camera.jpg" width="90" height="90" /></td>
  2406. <td><input name="addtocart3" type="submit" value="Add to Cart" /></td>
  2407. </tr>
  2408. <tr class="border_bottom">
  2409. <td>#4</td>
  2410. <td>Shoes</td>
  2411. <td>Bettans, 60 Leather Shoes, Brown</td>
  2412. <td>$23</td>
  2413. <td><img src="img/shoes.jpg" width="90" height="90" /></td>
  2414. <td><input name="addtocart4" type="submit" value="Add to Cart" /></td>
  2415. </tr>
  2416. </table>
  2417. </div>
  2418. </div>
  2419. <div class="myfooter">
  2420. <h3 style="font-weight:normal; padding-left:10px">&copy; </h3>
  2421. </div>
  2422. </form>
  2423. </div>
  2424. </body>
  2425. </html>
  2426. error.jsp
  2427. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  2428. <!DOCTYPE html>
  2429. <html>
  2430. <head>
  2431. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  2432. <title>JSP Page</title>
  2433. </head>
  2434. <body>
  2435. <h1>Hello World!</h1>
  2436. </body>
  2437. </html>
  2438. OUTPUT:
  2439.  
  2440. abc
  2441.  
  2442.  
  2443. © 2006 - 2018 Paste2.org.
  2444. Follow paste2.org on Twitter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement