________ _______ __ __ _______ ___
/ ____/ |/ / __ \/ / / / < / __ < / Spring 2019 Section 54
/ / / /|_/ / /_/ / / / /_____/ / / / / /
/ /___/ / / / ____/ /_/ /_____/ / /_/ / / Assignment 1
\____/_/ /_/_/ \____/ /_/\____/_/ Thursday, 31st September, 2019
ASSIGNMENT IS DUE AT THE BEGINNING OF THE NEXT CLASS.
=====================================================================================
Before you begin, press CTRL+ALT+T. This will bring up a terminal window, which is
a quick way to access your network directory. Once it's open, type:
mkdir asmts
cd asmts
mkdir asmt1
cd asmt1
When you save your work today (which you should do often), you should make sure that
you save it in the asmts/asmt1 directory. THIS IS IMPORTANT!
-------------------------------------------------------------------------------------
Please provide AT LEAST THREE examples of your function running.
=====================================================================================
1. Write a function SQ which takes one number as an input and outputs the square
of that number.
Example output:
> (sq 3)
9
> (sq -5)
25
> (sq 47)
2209
2. Write a function CUBE which takes one number as an input and outputs the cube
of that number.
Example output:
> (cube 3)
27
> (cube -2)
-8
> (cube 1701)
4921675101
3. Write a function HELLO which takes one value as an input and prints a nice greeting
on the screen.
Here is some sample output:
> (hello 42)
Hello 42, nice to meet you!
> (hello "world")
Hello world, nice to meet you!
> (hello "Captain Kirk")
Hello Captain Kirk, nice to meet you!
4. Write a function VAL which takes a number as input and prints out the square and cube
of that number using the PRINTF command.
Example output:
> (val 4)
4 squared is 16 and 4 cubed is 64.
> (val -2.48)
-2.48 squared is 6.1504 and -2.48 cubed is -15.252992.
> (val 5)
5 squared is 25 and 5 cubed is 125.
You may not use any arithmetic functions in this problem (i.e. no *, +, - or /).
(Hint: do you have anything already which might be useful?...)
5. The surface area of a sphere with radius R may be calculated using the formula
2
A = 4 * PI * R
and its volume with the formula
3
V = 1.33333 * PI * R
Write a function SPHERE which takes one number as an input and prints the
radius and volume of the sphere using the PRINTF command.
You may use the value 3.1415926 for PI.
Example output:
> (sphere 1)
Sphere with radius 1 has surface area 12.5663704 and volume 4.188779661358.
> (sphere 2)
Sphere with radius 2 has surface area 50.2654816 and volume 33.510237290864.
> (sphere 9.5)
Sphere with radius 9.5 has surface area 1134.1149286 and volume 3591.354962156815.
(Hint: do you have anything that might be useful?...)
------------------------------------------------------------------------------------------
Don't forget to submit your work using the SUBMIT101 command!
submit101 e-asmt1 asmt1
(If the name of your directory is different from 'asmt1', change 'asmt1' to whatever
the name of your directory is.)
==========================================================================================
==========================================================================================