# pseudocode and modular design



## Jdub72 (Jul 17, 2010)

Help! I'm new to programming, so i wonder if anyone can help me. Having trouble with creating a modular design for this pseudocode:


Start
Display “Employee Pay Calculator”
Display “Simply input required info to calculate employee pay.”
Set employeeName = Matthew Robinson
Display “What is employee’s name?” 
Input employeeName
Set hoursWorked = 40
Display “What are his/her total hours worked?”
Input hoursWorked
Set hourlyPay = 10
Display “What is employee hourly rate?”
Input hourlyPay
Set grossPay = hoursWorked * hourlyPay
Display “Employee gross pay is:”
Input grossPay
Display “Program Complete.”







Stop
Can anyone help me?


----------



## AwesomeOpheliac (Jul 16, 2010)

hi, 

I don't think a code like this would need to be modular, I suppose it could be a module in an entire program. 

I'm also a bit hesitant, seeing as i've only been programming for around two years, but i think your pseudo code is wrong... or maybe its just what i have been taught, but if i was going to display that pseudo code it would go something like this,

```
START
     SET employeeName = Matthew Robinson
     SET hoursWorked = 40
     SET hourlyPay = 10
     PRINT “Employee Pay Calculator”
     PRINT “Simply input required info to calculate employee pay.”
     PRINT“What is employee’s name?”
          INPUT employeeName
     PRINT“What are his/her total hours worked?”
          INPUT hoursWorked
     PRINT“What is employee hourly rate?”
          INPUT hourlyPay
     PRINT “Employee gross pay is:”
          PRINT "hoursWorked * hourlyPay"
     PRINT “Program Complete.”
END
```
ok, i'm not sure what you have been taught but you should stick to that, but if you look at the way I have set out the pseudo code you should see that I input all of the data first, and then display the relevant information. i also use print instead of display, but this once again is down to your school of programming.

the reason i did this pseudo code the way i did is because i program in php, and so i would have previously captured all of the variables

if you have a wamp server(http://lmgtfy.com/?q=wamp) you can run process below as long as the two files are in the same folder in your server


_save this file as : process.php _

```
<?php
//[email protected] Creator (^_^)
if (!isset($_POST['name']))
	{
		echo"Employee pay calculator</br> Simply input required info to calculate employee pay";
		require('employee_form.php');
	}
	else
	{
		echo"Employee pay calculator</br> Simply input required info to calculate employee pay";
		require('employee_form.php');
		$name = $_POST['name'];
		$hours = $_POST['hours'];
		$pay = $_POST['pay'];
		$earn = "$hours" * "$pay";
		echo"$name worked for $hours for $pay an hour, and so should earn $$earn";
	}
?>
```

_save this file as : employee_form.php _

```
<form name="form1" method="post" action="process.php">
  <table width="0" border="0">
    <tr>
      <td>Employee's Name</td>
      <td><label>
        <input type="text" name="name" id="name">
      </label></td>
    </tr>
    <tr>
      <td>Hours Worked</td>
      <td><label>
        <input type="text" name="hours" id="hours">
      </label></td>
    </tr>
    <tr>
      <td>Employee's pay</td>
      <td><label>
        <input type="text" name="pay" id="pay">
      </label></td>
    </tr>
    <tr>
      <td> </td>
      <td><label>
          <input type="submit" name="submit" id="submit" value="Calculate!">
      </label></td>
    </tr>
  </table>
</form>
```


----------

