Advertisement
Guest User

Untitled

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