Professional Documents
Culture Documents
Assignment 1 (Assigned: Wednesday, May 10, 2017, Due: Friday, May 19, 2017)
Exercises
(NO programming required; Your submission should be a .doc, .docx, .odt, .pdf, … document, or a .bmp, .png, .jpg, … image or scan
of your work; 1 + 2 + 2 = 5 Marks)
int x = 5;
int y = y * x;
2. Convert 2073(10) from decimal to binary, showing the steps of your computation.
3. Convert 100111(2) from binary to decimal, showing the steps of your computation.
Programming
(5 + 5 = 10 Marks)
1. Write a program to compute, and output to the screen, the number of cat treats that can be bought from a vending machine,
along with amount of resulting change. Each treat costs 47¢ and purchases are made in whole-dollar increments, such as $1, $2, $3,
$4, $5, ..., that are input, via the keyboard, by the user. For example, if a person inserts $ 4, they will recieve 8 treats and 24¢ change.
Your submission should include a screenshot of the execution of the program using each of the values $1, $7 and $29.
2. Write a program to compute, and output to the screen, the value of the variable x of the polynomial x2 + 2x + 1 = p, for some
constant p ≥ 0 that is input, via the keyboard, by the user. For example. If p = 9, then x = 2. Your submission should include a
screenshot of the execution of the program using each of the values p = 0.14, 16, 151.93.