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...
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....
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...
You are required to use C++ static or dynamic arrays of characters to store c-strings. You...
You are required to use C++ static or dynamic arrays of characters to store c-strings. You are NOT allowed to use any C++ string data type variable for any purpose. Moreover, you are allowed to add any include directive. You are not allowed to include string, cstdlib or math libraries. Also, you are not allowed to use any built-in functions of c-strings. can someone help with the third, fourth, and fifth functions? I tried many ways but i cannot figure...
You are required to use C++ static or dynamic arrays of characters to store c-strings. You...
You are required to use C++ static or dynamic arrays of characters to store c-strings. You are NOT allowed to use any C++ string data type variable for any purpose. Moreover, you are allowed to add any include directive. You are not allowed to include string, cstdlib or math libraries. Also, you are not allowed to use any built-in functions of c-strings. can someone help with the third, fourth, and fifth functions? I tried many ways but i cannot figure...
This is a C++ assignment The necessary implementations: Use arrays. Write some functions. Practice processing lists...
This is a C++ assignment The necessary implementations: Use arrays. Write some functions. Practice processing lists of values stored in an array. Write a modular program. Sort an array. Requirements to meet: Write a program that asks the user to enter 5 numbers. The numbers will be stored in an array. The program should then display the numbers back to the user, sorted in ascending order. Include in your program the following functions: fillArray() - accepts an array and it's...
answer in JAVA language please In this assignment you will use: one-dimensional arrays; strings and various...
answer in JAVA language please In this assignment you will use: one-dimensional arrays; strings and various string-handling methods; file input and output; console input and output; loops; and conditional program statements. Instruction You are asked to write a program that translates a Morse code message into English language. The program will ask the user to enter filenames for two input files, one for the code translation table data and the other for the coded message data, as well as an...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT