IPT - A Virtual Approach IPT A Virtual Approach by Peter Whitehouse
Quick Links:
Information and Intelligent Systems Social and Ethical Implications Human Computer Interaction Software and Systems Engineering eXercise Files Course Outline and Assessment A-Z of Geeky Acronyms Terrace Work Program 2004 Sillybus FAQ = Frequently Asked Questions Help

eXercise #7

Iteration using REPEAT...UNTIL

  1. Write a program which accepts integers from the keyboard (one per line) and which finds the largest number input. The user terminates input by typing zero.

  2. Change the program in Question 1 so that instead of the largest number being found, the smallest is found. Note that 0 is used to terminate input and is not to be considered as a number when determining the smallest number. Note also that negative integers should be ignored.

  3. Write a small fragment which refuses to let a user go until s/he has typed either a 'Y' or 'y' (for 'Yes') or an 'N' or 'n' (for 'No') in response to the prompt:
       Finished? (Y/N)

    For example,

    	Finished? (Y/N) p
    	Finished? (Y/N) x
    	Finished? (Y/N) 8
    	Finished? (Y/N) n

  4. Consider the following sequence of numbers which is called the Fibonacci sequence. What is the rule for generating the numbers?
           1 1 2 3 5 8 13 21 ...

    Write a small program which generates and writes the Fibonacci numbers stopping when the first value exceeds 1000.

  5. With the help of a repeat statement, write a small program which prints random capital letters across a line until it accidentally writes 'Z', at which time it stops.

  6. You are to construct a MENU system that allows the user (a checkout lifeform at a fast food outlet) to take an order, and present a bill at the end.

    The Order screen will resemble the following:

    Your Choices are:
    1. French Flies
    2. Tuna Thickshake
    3. Big Muck
    4. Fillet of Roach

    5. Finished this order
    6. Exit Program

    Your Selection: _

    Using an inputbox to harvest CHARACTER choices from the user, cumulatively tally products until the user requests the bill, then present them with a billing screen similar to the following:

    Your order includes:
    1 Tuna Thickshake $ 1.20
    2 Big Mucks $ 5.00
    1 Fillet of Roach $ 2.15
    Totalling $ 8.35
    Invent prices for your products, and use labels to position your output accurately.

    'Experts' would ensure that the grammar of each bill line was correct (ie. 1 Big Mucks is not correct) and if a particular product was unordered it should not appear on the bill. Once you get it working for ONE order, show your teacher and then allow it to take many orders (one after the other)

    You will find an algorithmic plan here should you get lost.


©Copyright t 1992..2018+. Edition 26.150117
Creative Commons License
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 2.1 Australia License