You are on page 1of 1

Pascal Tasks III

For each of the following tasks:

 Write a basic algorithm (plan your program)


Type the code into the Pascal editor
Compile the code [ ALT & C]
Run the code [ALT & R]
 Test the code – check that the answers are correct

1. Create a shopping till to add up the cost of a series of purchases. Your program must:
 Accept amounts from the user
 Subtotal the amounts
 Provide a final total
 Accept payment
 Calculate change
 Return change

Advanced:
 Allow the user to clear the last entry

2. Create a program which tests an integer for a prime number. Your program must:
 Accept a positive integer from the user
 Test the number to determine whether or not it is a prime number
 Return a message to the user indicating whether or not the input was a prime number
 The program should continue to run until the user chooses to exit the program

3. Generate a series of prime numbers up to a given integer. Your program must:


 Accept an integer from the user
 Test that the number provided is a positive number
 If the number is negative, request a new number from the user
 Generate a series of primes up to the input number
 Display the prime numbers generated
 The program should continue to run until the user chooses to exit the program

Advanced:
 Accept the number in a suitable format and write validation code to ensure it is an
integer

You might also like