Q1. rewrite the exercise on April 4 by adding the following operations:
1) In the php script, create an associative array named $order that stores the following values:
- the number of cheese toppings;
- the number of pepperoni toppings;
- the number of ham toppings;
- the size of the ordered pizza;
- the number of the ordered pizza;
- the total cost of the order;
- the discount rate;
- the total cost after the discount.
2) the script assigns the values collected from the following fields:
- the number of each topping;
- the size of the ordered pizza;
- the number of the ordered pizza;
as the values of the elements of this array.
3) after calculating the total cost for an order, add the following values as the values of the elements of this array:
- the total cost of the order;
- the discount rate;
- the total cost after the discount;
as the values of the elements of this array.
4) applying foreach loop to print each element (key and value) of the associative array as a table. The text alignment, font size, and text color will be specified by a embedded css script that is generated by the php script.
exercise on April 4 code
// 1.html
<html>
<head>
<title>Pizza</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2>Pizza Order Form</h2></br>
<form id="pizzaform" action="1.php" method="post">
<p>Provide what you like and then you will know your total
cost for your order.</p></br>
<label for="cheese">the number of cheese
toppings</label>
<input id="cheese" type="text"
name="cheese"></br></br>
<label for="pepperoni">the number of pepperoni
toppings</label>
<input id="pepperoni" type="text"
name="pepperoni"></br></br>
<label for="ham">the number of ham
toppings</label>
<input id="ham" type="text"
name="ham"></br></br>
<label for="size">the size of the selected
pizza</label>
<select id="size" name="size">
<option value="small">Small</option>
<option value="medium">Medium</option>
<option value="large">Large</option>
</select></br></br>
<label for="pizzas">how many pizzas do your
order?</label>
<input id="pizzas" type="text"
name="pizzas"></br></br>
<button id="total" onclick="return validate()"
name="calculate">Calculate Total</button>
<button
onclick="clear()">Reset</button>
</form>
<script>
function validate() {
var value = true;
var cheese = document.getElementById("cheese");
if(cheese.value<0||cheese.value>10) {
alert("the number of the toppings must be
0<=cheese<=10");
value = false;
}
var pep = document.getElementById("pepperoni");
if(pep.value<0||pep.value>10) {
alert("the number of the toppings must be 0<=pep<=10");
value = false;
}
var ham = document.getElementById("ham");
if(ham.value<0||ham.value>10) {
alert("the number of the toppings must be 0<=ham<=10");
value = false;
}
var pizzas = document.getElementById("pizzas");
if(pizzas.value<1||pep.value>=10) {
alert("the number of the toppings must be 1<=number of
pizzas<10");
value = false;
}
return value;
}
function clear() {
document.getElementById("pizzaform").reset();
}
</script>
</body>
</html>
// 1.php
<?php
if(isset($_POST['calculate']))
{
$cheese = $_POST['cheese'];
$pepperoni = $_POST['pepperoni'];
$ham = $_POST['ham'];
$size = $_POST['size'];
if($size=="small")
$size = 10;
elseif ($size=="medium")
$size = 12;
elseif ($size=="large")
$size = 14;
$pizzas = $_POST['pizzas'];
$total = $pizzas*($size+$cheese*2+$pepperoni*2+$ham*2);
$discount = 0;
if ($total>30 AND $total<=50)
$discount = 5;
elseif ($total>50 AND $total<=75)
$discount = 10;
elseif ($total>75 AND $total<=100)
$discount = 15;
elseif ($total>100)
$discount = 20;
else
$discount = 0;
$payment = ($total - ($total * ($discount / 100)));
}
?>
<html>
<head>
<link rel="stylesheet" href="main.css">
<title>Order</title>
</head>
<body>
<p class="large">We have received your order, thank you!</p>
<p class="large">The detail of your order is below:</p>
<ul>
<li>the number of cheese toppings=<?php echo $cheese;?></li>
<li>the number of pepperoni toppings=<?php echo $pepperoni; ?></li>
<li>the number of ham toppings=<?php echo $ham; ?></li>
<li>the size of the ordered pizza=<?php echo $size; ?></li>
<li>the number of the ordered pizza=<?php echo $pizzas; ?></li>
</ul>
<h1>Your total cost is: <?php echo $total; ?></h1>
<table border="1">
<tr>
<th colspan="8">Order Information</th>
</tr>
<tr>
<td colspan="3" align="center">toppings</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>cheese</td>
<td>pepperoni</td>
<td>ham</td>
<td>size</td>
<td>number</td>
<td>cost</td>
<td>discount</td>
<td>payment</td>
</tr>
<tr>
<td><?php echo $cheese;?></td>
<td><?php echo $pepperoni; ?></td>
<td><?php echo $ham; ?></td>
<td><?php echo $size; ?></td>
<td><?php echo $pizzas; ?></td>
<td><?php echo $total; ?></td>
<td><?php echo $discount; ?></td>
<td><?php echo $payment?></td>
</tr>
</table>
</body>
</html>
// style.css
body
{
background-color: pink;
}
label,p,h2
{
color: blue;
}
#total
{
margin-left: 80px;
}
h1
{
color: red;
}
.large
{
color: black;
font-size: 105%;
}
// webpage screenshots
<!-- 1.php -->
<?php
if(isset($_POST['calculate']))
{
//------------------------------------------------------------
//ANSWER-1 FROM HERE
$order = array(
'cheese' => 0,
'pepperoni' => 0,
'ham' => 0,
'size' => 0,
'pizzas' => 0,
'total' => 0,
'payment' => 0,
'discount' => 0,
);
//------------------------------------------------------------
//ANSWER-2 FROM HERE
$order['cheese'] = $_POST['cheese'];
$order['pepperoni'] = $_POST['pepperoni'];
$order['ham']= $_POST['ham'];
$order['size'] = $_POST['size'];
if($order['size']=="small")
$order['size'] = 10;
elseif ($order['size']=="medium")
$order['size'] = 12;
elseif ($order['size']=="large")
$order['size'] = 14;
$order['pizzas'] = $_POST['pizzas'];
//------------------------------------------------------------
//ANSWER-3 FROM HERE
$order['total'] = $order['pizzas']*($order['size']+$order['cheese']*2+$order['pepperoni']*2+ $order['ham'] *2);
$order['discount'] = 0;
if ($order['total']>30 AND $order['total']<=50)
$order['discount'] = 5;
elseif ($order['total']>50 AND $order['total']<=75)
$order['discount'] = 10;
elseif ($order['total']>75 AND $order['total']<=100)
$order['discount'] = 15;
elseif ($order['total']>100)
$order['discount'] = 20;
else
$order['discount'] = 0;
$order['payment'] = ($order['total'] - ($order['total'] * ($order['discount'] / 100)));
}
//------------------------------------------------------------
?>
<html>
<head>
<link rel="stylesheet" href="main.css">
<title>Order</title>
<style>
body{
color : red;
}
#header{
color : black;
}
</style>
</head>
<body bgcolor="#ffda90">
<b id = "header"> Order Information </b>
<p>
<table border="1" cellpadding="4" cellspacing="4" width="20%">
<!--ANSWER-4 FROM HERE -->
<?php
foreach ($order as $key => $value) {
if($key == 'payment')
$key1 = "after_reduction";
else
$key1 = $key;
if($key1 == 'after_reduction' || $key1 == 'total')
echo "<tr><td><center>".$key1."</center></td><td><center>$".$value."</center></td></tr>";
else if($key1 == 'discount')
echo "<tr><td><center>".$key1."</center></td><td><center>".$value."%</center></td></tr>";
else
echo "<tr><td><center>".$key1."</center></td><td><center>".$value."</center></td></tr>";
}
?>
<!--ANSWER-4 ENDS -->
</table>
</body>
</html>
Q1. rewrite the exercise on April 4 by adding the following operations: 1) In the php...
PHP Can't get my code to work, what am I doing wrong? <!DOCTYPE html> <html> <head> <script> </script> </head> <body> <h2>Temperature Conversion Table</h2> <h4>Enter a starting value in degrees Fahrenheit and an increment value.</h4> <form name="myTemp" onsubmit="convertCelcius()" method="post"> <input type="text" name="temperature"> Enter an value in degrees Fahrenheit<br><br> <input type="radio" name="degIncrement" id="degIncrement5"> Convert in increment in 5 degrees<br> <input type="radio" name="degIncrement" id="degIncrement10"> Convert in increment in 10 degrees <br/><br/><input type="submit" value="Submit"> </form> <?php if( $_POST["temperature"] || $_POST["degincrement"] ) { //get he...
LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but, I keep getting an error that I coded "Wrong username and password!" ***PLEASE DONT GIVE ME A NEW CODE THAT IS NOWHERE NEAR THE CODE I SUBMITTED***** PLEASE LOOK AT THE CODE AND SEE ANY ISSUES login.html <!DOCTYPE html> <html> <head> <title>login popup</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <style type="text/css"> body { background-color: white; } </style> </head> <body> <center> <h1 style="text-align: center;"> Login </h1> <form> Login ID:...
C# Programming Exercise and Bonus Exercise (Next Page) 1) Define a class called OrderPizza that has member variables to track the type of pizza being order (either deep dish, hand tossed, or pan) along with the size (small, medium or large), type of toppings (pepperoni, cheese etc.) and the number of toppings. Create accessors for each property (ex.: type, size, type of toppings, and number of toppings). Implementation class should have a CalculateOrderPayment method to compute the total cost of...
I have the code buts its not working as this below instruction can anyone help Use the requirements from the pizza part of Assignment 6 and do the following using CSS and an internal style sheet: 1. Your Javascript function should be in an external file (don’t forget to move it up to studentweb too) 2. Put a red border of 300px in width around the form 3. There should be three Div sections: header, main_body, and footer. 4. Center the name of your...
New Perspectives on HTML5 and CSS3. Solve Chapter 13 Case Problem 3. mas_register.js "use strict"; /* New Perspectives on HTML5, CSS3, and JavaScript 6th Edition Tutorial 13 Case Problem 3 Filename: mas_register.js Author: Date: Function List ============= formTest() Performs a validation test on the selection of the conference session package and the conference discount number calcCart() Calculates the cost of the registration and saves data in session storage writeSessionValues() Writes data values from session storage in to the registration...
Hello can someone help me in my code I left it as comment task #0, task#1, task#2a and task#2b the things that I am missing I'm using java domain class public class Pizza { private String pizzaCustomerName; private int pizzaSize; // 10, 12, 14, or 16 inches in diameter private char handThinDeep; // 'H' or 'T' or 'D' for hand tossed, thin crust, or deep dish, respecitively private boolean cheeseTopping; private boolean pepperoniTopping; private boolean sausageTopping; private boolean onionTopping; private boolean...
Create an HTML5 page that contains a form to collect the following data. The text in bold indicates the id value that should be assigned to each html control: Product (drop down list) product – iPad, iPhone 6S, Galaxy 5S, Moto X, and so on Quantity (number) quantity Unit price (number) unit_price Discount (%)(number) discount_rate Date (date) order_date First Name (text box) first_name Last Name (text box) last_name Payment type (drop down list) payment_type – Visa, Master, Discover, Amex, and...