Friday 25 April 2014

Coding: Quiz 1

Quiz:

There are four questions and each are worth 25%.  
You have two hours to do the quiz.  Plan your time accordingly.  
It is open book. You may use the following to help you.
      1) programs you have written previously.
      2) the internet (for examples, to look up conversion formulas etc.)
      3) all course notes on the wiki page.
      4) khan academy (your programs and/or videos)
You may not discuss your with each other.


1) Write a program that outputs the following patterns. Use at least one loop.

a.)
*
**
***
****
*****

b.)
++++1
+++22
++333
+4444
55555


=====================
2.  Write a program that 
    1) Asks the user if they want to convert miles to kilometres or kilometres to miles.
    2) Reads the input and does the conversion.
    3) Prints the result to the screen.

=====================
3.  Write a program that 
    1) Asks the user if they want to convert pounds to kilograms or kilograms to pounds.
    2) Reads the input and does the conversion.
    3) Prints the result to the screen.
=====================

4.  Write a program that
    1) Asks the user for a number between 1 and 512.
    2) Print out the multiples of that number up to 12.

    e.g.
    Enter a number
    512
    0 * 512 = 0
    1 * 512 = 512
    2 * 512 =  1024
    .
    .
    .
    12 * 512 = 6144


Evaluation:

1.

*, **, ***, ****, *****    

 [4] is +5
 [3] is +4
 [2] is +3
 [1] is +2
 [0] is +1


2.  Correct.  Nice precision!  

3. Correct.  Nice precision!  

4.  Correct.


Mark 16 out of 20.    Well done!

Question 1a -1  Using one System.out.println for each would do the job.


Question 1 b)  - 3 desired output was:
++++1
+++22
++333
+4444
55555


No comments:

Post a Comment