%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% Name: Michael Litvak %%%%%%
%%%%%% Date: Sept. 14 %%%%%%%%%%%%
%%%%%%%% Title: ICS 2 %%%%%%%%%%%%
%Purpose: To create a program using loops %%
%%%%%%%%%%%% SCREEN SETTINGS %%%%%%%%%%
View.Set ("graphics:400;400,nobuttonbar")
setscreen ("offscreenonly")
drawfillbox (400, 0, 0, 400, black)
%%%%%%%%%%%%%% FONT SETTINGS %%%%%%%%%%%
% The "Font.Draw" program.
var font1, font2 : int
font1 := Font.New ("arial:35")
assert font1 > 0
font2 := Font.New ("comic sans ms:18:bold")
%%%%%%%%% VAR DECLARATIONS %%%%%%%%
var total_q1 : int
%%%%%% SET KEYBOARD CHARS %%%%%%%
var chars : array char of boolean
Input.KeyDown (chars)
%%%%%%%%%%%%%%%%%%% Question 1 %%%%%%%%%%%%%%%%
proc question1
total_q1 := 0 % set variable
%colour settings
colorback (black)
color (white)
for i : -100 .. 100 by 2
drawfillbox (400, 0, 0, 400, black) %background
delay (50)
locate (2, 19)
put " QUESTION 1" ..
locate (4, 1)
put "This program runs numbers from -100 to 100 by 2s and displays running total as it runs"
Font.Draw ("Number count: ", 1, 250, font2, white)
Font.Draw (intstr (i), 160, 200, font1, yellow) %draws numbers count
total_q1 := total_q1 + i %calculation total
Font.Draw ("Running total: ", 1, 140, font2, white)
Font.Draw (intstr (total_q1), 150, 90, font1, yellow) %draws running total
Font.Draw ("_________________", 0, 170, font1, white) %seperator
Font.Draw ("_________________", 0, 80, font1, white) %seperator
Font.Draw ("_________________", 0, 280, font1, white) %seperator
Font.Draw ("____", 145, 375, font1, brightgreen) %seperator
View.Update %update the screen
end for
end question1
%%%%%% MAINE LINE %%%%%%%%%%
colorback (black)
color (white)
loop
Input.KeyDown (chars)
colorback (black)
color (white)
put "Press the number of the question"
put "1. Question 1"
locate (1, 1)
if chars ('1') then
question1
end if
end loop
|