Asg 1: Trip Budget

Objectives

Implement a simple trip budget where, given a total dollar amount and proportions (percent) devoted to two cities, Antwerp and Bloemfontein, the program calculates the amount of money available for Antwerp, Bloemfentein, and Cancun, in the denominations of the given country.

Assignment

  1. Use a combination of printf() and scanf() to prompt the user for the total budget, and the proportion of the amount to use for Antwerp and Bloemfontein.
  2. Compute the amount of money per each of three cities: Antwerp, Bloemfontein, and Cancun, given the entered percentages and what's left over.
  3. Convert the dollar amounts into:

Details

  1. Your code should check of erroneous input, e.g., whether the entered percentages make sense (all three do not exceed 100%).
  2. The input percentages should be entered in as fractional amounts, e.g., .33 for 33%.
  3. The program should output the final budget amounts for each city.

Example Input

  1. The user is prompted to enter in the numerical values:
    Enter total budget: 1000
    Enter Antwerp proportion: .33
    Enter Bloemfontein proportion: .33
    Total budget is: 1000
    	

Example Output

  1. The program outputs the budgeted amounts per city:
    Antwerp budget is: 253.73 euros
    Bloemfontein budget is: 2383.59 rands
    Cancun budget is: 3729.97 pesos
    	

Supplemental

  1. If you call your source code file main.c here is a Makefile that you can use to try to compile the project:
    CC = gcc
    
    .c.o:
    	$(CC) -c -o $@ $<
    
    all: main
    
    main: main.o
    	$(CC) -o $@ $@.o
    
    main.o: main.c
    
    clean:
    	rm -f *.o
    	rm -rf main
    	
    Note that each line underneath the targets is indented by a tab, not just spaces, this is important!

Turn in

Turn in all of your code, in one tar.gz archive of your asg##/ directory, including:
  1. A README file containing
    1. Course id--section no
    2. Name
    3. Brief solution description (e.g., program design, description of algorithm, etc., however appropriate).
    4. Lessons learned, identified interesting features of your program
    5. Any special usage instructions
  2. Makefile
  3. source code (.h headers and .c source)
  4. object code (do a make clean before tar)

How to hand in

See handin notes

Grading scheme