CSC 160 - Computer Programming for Non-majors

Dr. R. M. Siegfried

Computer Science Assignment #8 - Software Testing

Due Tuesday, October 26, 2010

Software engineering is the discipline within computer science that tries to apply principles of engineering design to the development of software.

One example of this is the construction of a set of test data that accurately tests the ability of software to work correctly with any allowable set of inputs.

Given the program below, construct 8 sets of inputs that will test the ability of the program to spot potentially bad data that it is presented. What you will turn in is a copy of these sets of test data and the output from the program.


<html>
  <head> <title> CSC 160 - Lab 8 </title>
  </head>

  <body>
    <script type = "text/javascript">

       var rate, hours, gross;
    
       hours = parseFloat(prompt("How many hours did you work?", 0.0));
    
       if (hours < 0)
           alert(hours + " is not a valid number of hours.\n");
       else if (hours > 80)
         alert("It is not possible to work " + hours + " hours" 
                  + " in one week.\n");
       else {
         rate = parseFloat(prompt("How much do you make per hour?", 0.0));
    
         if (rate < 0)
             alert(rate + " is not a valid hourly rates.\n");
         else if (rate > 100)
           alert("NOBODY here makes $" + rate + " in one week.\n");
         else	{
           if (hours > 40)
             gross = rate * hours;
           else
             gross = 40*rate + 1.5*rate*(hours-40);

           gross = gross.toFixed(2);       
           alert("Your gross pay is $" + gross + "\n");
         }
       }
    </script>
  </body>
</html>

[Back to the Assignments Index]