Algorithm 1: Develop an Algorithm to compute the sum, difference, product and remainder of any two integers.
This problem requires the development of an Algorithm that will demonstrate the computation of the product, difference, remainder, and the sum of any two integers that will be selected.
The following therefore, outlines the input, the output and the processing of the computation process of the input to obtain output.
The input in this case is the two integers we shall select for the purpose of this computation. We shall call the first integer a and the second integer b. consequently, the value of a shall be 8, while that b shall be 12.
The sum of the two selected integers shall be 20.
The product of the two selected integers shall be 96.
The difference of the two integers shall be -4.
While the remainder of the two integers shall be 8.
If the integers are 8 and 12, the sum is obtained by adding the two. Therefore, Sum=8+12=20.
The product on the other hand is obtained by multiplying the two. Therefore, Product=8×12=96.
The difference is obtained by subtracting the second integer from the first integer. Therefore, Difference=8-12=-4.
The remainder on the other hand is obtained by bringing in the quotient. In this case, the quotient is 2/3. Therefore, the remainder is going to be 2.
Since the integer quotient, which is 0 has be considered in the computation, the output is protected by the divide-by-zero-error.
Print the results
Algorithm 2: Develop an Algorithm to read an employee’s total weekly hours worked and rate of pay. Determine the gross weekly pay using “time and a half” for anything over forty hours. Include error handling for zero or negative hours and rate of pay.
Develop an Algorithm to read an employee’s total weekly hours worked and rate of pay.
The problem requires:
The program for summing any two numbers.
The prompt user to be used in entering the two numbers.
The memory boxes into which the two users numbers are taken.
The two numbers to be added and the sum to be stored in another box.
Printing of results.
The two numbers are the input.
This is the quotient obtained from the two numbers.
The user prompt is written so that the two whole numbers are entered.
Checking to know whether or not the second number is zero.
Outputting the error message and stopping the program if the second number is zero.
The division of the two numbers by each other and storage of results in a memory box if the second number is not zero.
The printing of results.
Determine the gross weekly pay using “time and a half” for anything over forty hours. Include error handling for zero or negative hours and rate of pay.
The problem definition
The problem requires the writing of a message that describes the program to the user. The user prompt is also written that will enter the rate of pay as Rate.
The user input is taken into the Rate box.
A user prompt is written to be used for entering weekly hours worked as Hours.
The user input is taken into Hours box.
For hours <=40, the Gross is calculated as, Gross=Rate×Hours.
If the Hours are greater, Gross is calculated as = (40 × Rate) + [1.5 × (Hours – 40) × Rate].