simple calculator problem

Discussion on PHP Scripting
no avatar
emmahughes18
 
Posts: 1
Joined: Sun Jul 24, 2011 1:07 am

simple calculator problem

by emmahughes18 » Sun Jul 24, 2011 1:16 am

Hello everyone, I am having a problem working out the php bit for a simple calculator I have to make using radio buttons. I've got the html part a done but i'm stuck with the php script that follows for part b. Can anyone pleeease help me with this? Below is my whole task. :(

Q1. Simple Calculator
a. Create an html file with a radio buttons to choose options and plus 4 textboxes for entry of
any 4 numbers (whole numbers). The numbers entered into the textboxes are to be posted
to a backend php program. The chosen option should also be posted to the backend php
program.
The options are:
Highest
Lowest
Average
Sort in ascending order (7 marks)

b. Create a php script to receive the selected option and the 4 textbox values. Use if statements to handle the options then perform the appropiate calculation printing out the 4 input numbers plus the result.
The program should first check that numbers have been entered in all textboxes, with an appropriate error message if incorrect.

For highest use the max() PHP function – e.g. max($a,$b,$c) returns the value of the variable
containing the highest number
For lowest use the min() PHP function
For average add the values and divide by 4
For sorting add the values into an array and use the sort function sort() –
e.g. $list = array($a,$b,$c) where the variables hold the numbers input
sort($list) sorts in order
$list[0] holds the first number, $list[1] holds the second etc

Return to PHP Script