Programming with Turing

REVIEW ASSIGNMENT #2

First try the following program .
A long jump athlete takes three runs.  The first run is 5.65 m, the second is 5.78 m, and the third jump is 5.84 m.  
Write a program that displays the athlete's name, the first jump (in metres), the second jump, and the third jump.
The program will finally display the average of three jumps
SOLUTION:

% variable declaration to list the variables used
% the name of the athlete is a string of characters and must be declared as a string
var name : string
% the variables jump1, jump2, jump3, and average include decimal numbers and must be declared as real 
% numbers
var jump1, jump2, jump3, average : real
% a prompt to ask the athlete's name
put "Enter athlete's name"
get name:*
% retrieves and displays the name of the athlete (echoes it back)
put "the name of the athlete is ", name, "."
% a prompt to ask for the length of the first jump
put "the length of the first jump is"
get jump1
% a prompt to ask for the length of the second jump
put "the length of the second jump is"
get jump2
% a prompt to ask for the length of the third jump
put "the length of the third jump is"
get jump3
% display the information obtained by the user 
put "the lengths of the jumps are ", jump1," ",jump2," ",jump3, " meters"
% calculate the average [jump1 + jump2 + jump3]/3
average := (jump1 + jump2 + jump3)/3
% display the average of the three jumps
put name," jumped an average of " , average, " meters".

The screenshot below shows the execution of the above program.

ASSIGNMENT:

Write a program that will input   a student's name and his/her marks in three classes: English, Mathematics, Science.
The program will then calculate the average, and finally output the student's name and average mark.

NB: The average is calculated by adding the three marks and dividing them by 3

The screenshot below shows the execution of the above program.

 BLOG

EVENTS
Calendar

HOMEWORK AREA

ADMIN

Webmaster's Profile

 

FEEDBACK Comments

CREDITS

COPYRIGHT

 NEWSLETTER

TEACHERS AREA

 

Quick Search

Last Update:  04/17/2006  You are visitor #:Free Web Page Hit Counters Free Hit Counter Welcome to clickandlearn

  Biology   Chemistry   Computer Engineering      Electronics    Mathematics   Physics   Science   Home

Contact Us