Basic JavaScript Programs

3.A. AIM: Write a JavaScript program to find the area of a circle using radius and PI (const)

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Area of Circle</title>
</head>
<body>
  <script>
    const PI = 3.14
    var radius = parseFloat(window.prompt("Enter radius of a circle"))
    document.write("Radius of circle is: "+radius)
    document.write("<br>Area of a circle "+(PI*radius*radius))
  </script>
</body>
</html>

3.B. AIM: Write JavaScript code to display the movie details such as movie name, starring, language, and ratings. Initialize the variables with values of appropriate types. Use template literals wherever necessary.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Book Movie Tickets</title>
</head>
<body>
  <script>
    var noOfTickets = parseInt(window.prompt("Enter number of tickets"))
    document.write("Price of each ticket : Rs. 150")
    document.write("<br>Number of Tickets : "+noOfTickets)
    var price = noOfTickets*150
    document.write("<br>Price is : "+price)
    document.write("<br>10% Discount : "+price*0.1)
    document.write("<br>Total Price : "+(price - (price*0.1)))
  </script>
</body>
</html>

3.C. AIM: Write JavaScript code to book movie tickets online and calculate the total price, considering the number of tickets and price per ticket as Rs. 150. Also, apply a festive season discount of 10% and calculate the discounted amount.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Movie Description</title>
</head>
<body>
  <h1>Movie Description</h1>
  <div id="moviedesc"></div>
  <script>
    var moviename = "Yama Gola"
    var hero = "Srikanth"
    var heroine = "Meera Jasmin"
    var language = "Telugu"
    var rating = 5.6
    let moviedesc = `Movie Name: ${moviename}
    <br>Starring: ${hero} and ${heroine}
    <br>Language: ${language}
    <br>Rating: ${rating}`
    document.getElementById('moviedesc').innerHTML = moviedesc
  </script>
</body>
</html>

3.D. AIM: Write a JavaScript code to book movie tickets online and calculate the total price based on the 3 conditions: (a) If seats to be booked are not more than 2, the cost per ticket remains Rs. 150. (b) If seats are 6 or more, booking is not allowed. (c) If seats are less than 6 give discount of 10% and calculate the discounted amount.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Book Movie Tickets</title>
</head>
<body>
  <script>
    var noOfTickets = parseInt(window.prompt("Enter number of tickets"))
    document.write("Price of each ticket : Rs. 150")
    document.write("<br>Number of Tickets : "+noOfTickets)
    var price = noOfTickets*150
    if(noOfTickets<=2){
      document.write("<br>Price is : "+price)
    }else if(noOfTickets>=6){
      document.write("<br>You exceed maximum limit.")
    }else{
      document.write("<br>Price is : "+price)
      document.write("<br>10% Discount : "+price*0.1)
      document.write("<br>Total Price : "+(price - (price*0.1)))
    }
  </script>
</body>
</html>