Question

In: Computer Science

This assignment is about creating a online movie rental store. Use arrays and loops for this...

This assignment is about creating a online movie rental store. Use arrays and loops for this assignment.

1) Create a web page containing a list of movie names available for rent (at least 10 movies), so that each time you visit the home page, you see a different order of movies in the list. The movie names are required, all other information is optional.)

2) The rental price for each movie ranges between $1.99 to $7.99.

            • Create an associative array with a code for the movie as the key (e.g., movie1, movie2, etc.) and the associated rental price as the value. Display the array using the print_r() function.        

            • Sort the array according to the rental price in ascending order. Display the array again using the print_r() function.    

            • Calculate and display the average rental price for a movie.

            • Find and display the two highest and two lowest rental prices.

Display these results on the same page.

Again, display appropriate warning/error messages as needed.

Solutions

Expert Solution

PHP program for given assignement is as bellow, if you have any query regarding program please do comment I will solve all your queries thank you.

<!DOCTYPE html>
<html>
<head>
<!-- Required meta tags-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes">
   <meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-store,no-cache">
<!-- Your app title -->
<title>Movies</title>
</head>
<body>
<div class="movies">
<h1>Movies</h1>
<ul>
<?php
//declared associative array movies
$movies= array(
"Avatar"=>"2","Inception"=>"2.5","Avengers"=>"4","Spiderman"=>"3.66","Deadpool"=>"5.44","Terminator"=>"6","Star War"=>"4","The Prestige"=>"3","Shadow"=>"4.65","Apollo"=>"2.3");
$movieNames=array_keys($movies);

//shuffling array to display list of movies in random sequence each time

shuffle($movieNames);
foreach($movieNames as $m)
{
echo "<li>".$m."</li>";
}

?>
</ul>
<?php
echo "<b>Array without sorting</b> <p>";
print_r($movies);
echo "<p/>";

//sorting array in ascending order
arsort($movies);
echo "<b> Array After Sorting </b><p>";
print_r($movies);
echo "<p/>";
$average = array_sum($movies)/count($movies);
echo "<b> Average Rental Of Movies Is</b><p>:$".$average."<p/>";
$l = array_slice($movies,0,2,true);
$m= array_slice($movies,count($movies)-2,count($movies));
echo "<br/><b>Highest Rental Prices:</b><p>";
$i=1;
foreach ($m as $key => $value) {
# code...
echo $i.")$".$value."<br/>";
$i++;
}
echo "<p/><b>Lowest Rental Prices:</b><p>";
$i=1;
foreach ($l as $key => $value) {
# code...
echo $i.")$".$value."<br/>";;
$i++;
}
echo "</p>";
?>
</div>


</body>
</html>


Related Solutions

Assignment - Store Design and code a HTML/CSS/JS based web application for your online store. Assignment...
Assignment - Store Design and code a HTML/CSS/JS based web application for your online store. Assignment Specification · Minimum of SIX web pages are required for this assignment: § One Landing/Container Page ( a page with logo) § One Home Page § Three or more Product Line Pages (pages with product and it information ) § One Order Page (for customer to order a product after view the profuct on the product page) · Build internal CSS style sheets in...
What impact did the advent of online video rentals and streaming have on the in-store movie...
What impact did the advent of online video rentals and streaming have on the in-store movie industry? Use the demand and supply diagram to illustrate your answer. Pay attention to how the equilibrium quantity and price adjust. Make state all your assumptions. (What impact did the advent of online video rentals and streaming have on the in-store movie industry? Use the demand and supply diagram to illustrate your answer. Pay attention to how the equilibrium quantity and price adjust. Make...
This assignment will acquaint you with the use of while loops and boolean expressions. You will...
This assignment will acquaint you with the use of while loops and boolean expressions. You will create a program that acts as a score keeper of a racquet ball game between two players. The program will continually ask the user who the winner of every point is as the game is played. It will maintain the scores and declare the match is over, using these rules: (1) A game is over when a. one of the players wins 7 points...
Please write about the documentary movie of (Inside Job) Movie Assignment as following questions below ....
Please write about the documentary movie of (Inside Job) Movie Assignment as following questions below . Don't write about Wall Street . This is the 2nd question posting 1. Discuss the serious ethical concerns for business in the "Inside Job movie". 1. How business was portrayed in the film of Inside Job. What you should find is that business is generally portrayed in negative terms. For example, most business people in these films are motivated by greed. There are exceptions....
Program Assignment 1 C++ please Instructions This assignment will require the use of three arrays, which...
Program Assignment 1 C++ please Instructions This assignment will require the use of three arrays, which will be used in parallel. Create a program that keeps track of the sales of BBQ sauces for a company. The company makes several different types of sauces, Original, Sticky Sweet, Spicy, Sweet Heat, Hickory Bourbon and Smokey Mesquite. One array will contain the names of the different BBQ sauces. This array will be initialized from a text file with the 6 different names....
Management Information System This assignment is about creating a blog and a research about working for...
Management Information System This assignment is about creating a blog and a research about working for The Office of Career Services at a school. Answer the following questions based on your team project The Office of Career Services. Pretty much we are making up this job so you can include any vendors and any inter-enterprise. (you can just make-up your own idea or use imagination) . What are CRM, ERP and EAI? Who are the major ERP vendors? Does your...
C++ Please Do not use loops!! Assignment : Dice Roll Redux In "Dungeons & Dragons" and...
C++ Please Do not use loops!! Assignment : Dice Roll Redux In "Dungeons & Dragons" and similar role-playing games, dice with different numbers of sides are used to determine the outcomes of events throughout the game. There are different dice for different occasions: 4-sided, 6-, 8-, 10-, 12-, and 20-sided dice are common. A required roll is typically designated <n>d<s> where <n> is the number of dice to throw and <s> is the number of sides on those dice. For...
Your task is to modify the program from the Java Arrays programming assignment to use text...
Your task is to modify the program from the Java Arrays programming assignment to use text files for input and output. I suggest you save acopy of the original before modifying the software. Your modified program should: contain a for loop to read the five test score into the array from a text data file. You will need to create and save a data file for the program to use. It should have one test score on each line of...
IN JAVA USING loops, Arrays, filewriter/reader/exceptions, I dont think we are allowed to use arraylists/algorithm constraints...
IN JAVA USING loops, Arrays, filewriter/reader/exceptions, I dont think we are allowed to use arraylists/algorithm constraints THE TWO FILES ARE LISTED AFTER THE QUESTION(CDDriver.java and TextMenu.java) Lab 14 Array of Objects and File IO The following exercises are to be completed during lab class. If you do not have time to finish during lab, they must be completed before the beginning of the following lab session. Set-Up  Import the following file (See below) o CDDriver.java o TextMenu.java Import the...
JAVA Lab Assignment #13:  Looping Lab with both types of loops. This lab demonstrates the use of...
JAVA Lab Assignment #13:  Looping Lab with both types of loops. This lab demonstrates the use of the While Loop and the Do While Loop as error checking mechanisms. You will be using each of these loops to solve the same problem. Please put them both in the same program. When you test the code, you will not see a difference in the way they execute - but there will be a difference in the logic when writing the code. You...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT