Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 3 A. Write a segment of server script that receive a vegetable\'s name

ID: 3709947 • Letter: Q

Question

QUESTION 3 A. Write a segment of server script that receive a vegetable's name from user input and thern display the colour of the vegetable. The available vegetables with colours are showing in the Table 1.1. For any vegetable that is not in the list, display "Unknown" for the colour Vegetables Colour Cucumber Green Pumpkin Orange BroccoliGreen Tomato Red BeetrootPurple Pe Yellow Table 1.1 a) Using if...else statement b) Using switch statement Save the document as VegetableColours.php Write a function definition called findSum () that determine the total of sum by adding a number in k-times. The two inputs (an integer number, num and k-times, k) are the parameter of the function. The function should return the result once completed. Write a segment of script to test run your function. Save the document as FindSumValues.php Write a script to remove the dash (-) that found in between the number of Malaysian Identification Card (MyKad). Write a function icDashRemover ) that receive an IC number, return the IC number without the dash and the gender. You are required to test the function with two inputs below icNo1: 570822-05-4564 icNo2: 610101-11-5327 Save the document as IcDetails.php Write functions with the use of random function (rand ()) to answer the questions below a)A function genEvenNumber ) that able to produce an even number between 10 to b) A function genMultiple5 that able to generate 10 numbers in multiple of 5 Save the document as Random Functions.php 50 between 1000 to 2000

Explanation / Answer

If you have any doubts, please give me comment...

A) VegetbleColours.php

<?php

if(isset($_POST['veg_name'])){

$vegetable = $_POST['veg_name'];

switch($vegetable){

case "Cucumber":

echo "Green ";

break;

case "Pumpkin":

echo "Orange";

case "Broccoli":

echo "Green";

case "Tomato":

echo "Red";

case "Beetroot":

echo "Purple";

case "Pepper":

echo "Yellow";

default:

echo "unknown";

}

}

else{

?>

<form action="" method="POST">

Vegetable Name: <input type="text" name="veg_name" /><br />

<input type="sumit" value="Get Color"/>

</form>

<?php

}

?>

B) FindSumValues.php

<?php

function findSum($num, $k){

$sum = 0;

for($i=0; $i<$k; $i++){

$sum += $k;

}

return $sum;

}

findSum(2, 10);

?>

C) icDetails.php

<?php

function icDashRemover($str){

$n_str = "";

for($i=0; $i<strlen($str); $i++){

if($str[$i]!='-')

$n_str .= $str[$i];

}

return $n_str;

}

echo icDashRemover("570822-05-4564");

echo icDashRemover("610101-11-5327");

?>

D) RandomFunctions.php

<?php

function genEvenNumber(){

$arr = [];

for($i=10; $i<=50; $i+=2){

$arr[] = $i;

}

return $arr;

}

function genMultiple5(){

$arr = [];

$i= 0;

while($i<10){

$num = rand(1000, 2000);

if($num%5==0){

$arr[] = $num;

$i++;

}

}

return $arr;

}

?>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote