COMP1721 - Higher Computing 1B

Computing 1B - Week 11 Tutorial Questions

  1. The ATMega 64 has 48 bi-direction I/O lines? How do you configure and use them as inputs or outputs?

  2. Why would AVR code have a pointless loop like this:
    
    for (int j = 0; j < 30000; j++)
        ;
    
    Is this appropriate on machine with multiple processes?

    Is it sure to work?

  3. This loop when run on a CSE AVR board didn't terminate.
    
    for (int j = 0; j < 50000; j++)
        ;
    
    Why not?

  4. What does this program print?
    
    #include "cse_avr_board.h"
    
    int
    main(void) {
        uart_puts("8-bit counter\n");
    }
    

  5. You graduate from UNSW and look for a job. Unfortunately your COMP1721 mark is poor because you talked in lectures.

    The only employer who will hire you is a local convenience store. The convenience store owner asks to you to write a billing system for the store.

    The billing system must maintain a database of the prices of each item sold by the store. It also must print a bill for each customer.

    Each item sold by the store can be uniquely identified by its barcode. A barcode is an integer of up to 8 digits.

    Your billing system must read in commands setting the price of items and commands specifying the items a customer has bought.

    Your billing system, should read in commands setting prices like this:


    Kensington Kwiki-Mart Billing System
    Enter Command: price
    Enter barcode: 50653214
    Enter name of the item: Vegemite 455g
    Enter price: 2.99
    Enter Command: price
    Enter barcode: 93201704
    Enter name of the item: Milk 1L
    Enter price: 1.2
    Enter barcode: 83422184
    Enter name of the item: Peanut Butter 375g
    Enter price: 1.7
    

    Your billing system, should handle a change to the price of an item already in the database like this:


    Enter Command: price
    Enter barcode: 72012988
    Enter name of the item: Rinso - Economy Size
    Enter price: 7.20
    Enter Command: price
    Enter barcode: 72012988
    Enter new price for Rinso - Economy Size: 7.50
    Enter Command: 
    

    When your program is asked to print a bill it will be given the barcodes of the items purchased.

    The prices for these items will have been previously entered into the system as above.

    Note, we only want one line printed on the bill when a customer purchases several of the same item.

    Here is how your billing system should print a bill.


    Enter Command: bill
    Enter barcode: 72012988
    Enter barcode: 50653214
    Enter barcode: 93201704
    Enter barcode: 93201704
    Enter barcode: 83422184
    Enter barcode: 50653214
    Enter barcode: 93201704
    Enter barcode: 0
    1x Peanut Butter 375g @$1.70 = $1.70
    3x Milk 1L @$1.20 = $3.60
    2x Vegemite 455g @$2.99 = $5.98
    1x Rinso - Economy Size @$7.50 = $7.50
    Total: $18.78
    Thank for Shopping at Kensington Kwiki-Mart
    Enter Command: 
    

    Design your program from the top down.

    You should a number of classes in your program.

    Before writing any code for any methods, decide on the fields and method signatures for all classes.

    Implement methods from the top down.


Andrew Taylor (andrewt@cse.unsw.edu.au)
Higher Computing 1B, Computer Science & Engineering, UNSW