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

A) Write a php page that will ask the user to enter a number on a text box and t

ID: 3548397 • Letter: A

Question

A)

Write a php page that will ask the user to enter a number on a text box and then output a

message to indicate if the number is even or odd

Modify the above, in addition to output if the number is even or odd, output if the number is a

prime number.


B)


Write a php program that will ask the user to enter 2 integer numbers. Your program will

generate a table that list all the numbers between these two integers (inclusive). The first

column of each row of the table contains the number, the second column contains the square,

and the third column contains the cube. You may use either for loop or while loop.

Explanation / Answer

EVEN OR ODD:


$number = 20;

if ($number % 2 == 0) {

print "It's even";

}



PRIME:

function isPrime($num) {

//1 is not prime. See: http://en.wikipedia.org/wiki/Prime_number#Primality_of_one

if($num == 1)

return false;


if($num == 2)

return true;


  

if($num % 2 == 0) {

return false;

}


for($i = 3; $i <= ceil(sqrt($num)); $i = $i + 2) {

if($num % $i == 0)

return false;

}


return true;

}


Now I am sure you can do the third one yourself :) There is a lot of help available on the internet.

Cheers!

Do rate my efforts :)

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