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
 
 
Algorithms and Programming eXercises #10

Adding to the Environment - Solutions



1.	Type	rainbows = (red, orange, yellow, green, blue, indigo, violet);
		suits = (hearts, diamonds, spades, clubs);
		cardvalues = (ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king);
		states = (qld, nsw, vic, sa, wa, nt, tas);
		zodiacs = (aquarius, libra, taurus, gemini.... cant remember, dang);
		tvchannels = (abc, sbs, 9, 7, 10);
		eras = (precambrian, cambrian, mezozoic ...);
		manufacturers = (ford, holden, honda, mitsubishi, hyundai);

2.	Type 	emotions = (fear, anger, glad, sad);
		activeEmotions = (anger, glad);
		passiveEmotions = (fear, sad);
	Var	myPassiveEmotionalState : activeEmotions;
		myActiveEmotionalState : passiveEmotions;
	Begin
		myPassiveEmotionalState := fear;
		myActiveEmotionalState := glad;

3.	see Q9, Ex 12

4.	Program HiCard;
	{generates 2 cards and reports which is the highest - Ace = 1}
	Type cards : 0..51;
	Var	card1, card2: cards;
	Begin
		card1 := random(52);
		repeat
			card2 := random(52)
		until card2 <> card1;
		if (card1 mod 13) = (card2 mod 13)
			then writeln('IT IS A TIE!'
			else if (card1 mod 13) > (card2 mod 13)
						then writeln('CARD1 WON!')
						else writeln('CARD2 WON')
	End.


  

wonko@wonko.info
©Copyright t 1992..2017+. Edition 25.150117
wonkosite
Creative Commons License
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 2.1 Australia License
.