# Assignment 1: Coins calculator

Due: Monday, September 8th by 11:59 PM

## CS 200: Assignment 1 - Coins Calculator

This assignment is a warm-up exercise. Future assignments will be more difficult!

Write a program that solicits numbers of pennies, nickels, dimes, and quarters from the user and computes the total value of each denomination in cents and total monetary amount in both cents and dollars.

An example run of the program should look something like this.

### Getting Started

Download CS200_Assign1.zip. Import the contents of the zip file using Marmoset. You will modify the code in the file Coins.cpp.

You should store the number of each kind of coin (pennies, nickels, etc.) in a different variable. Use int as the type of each variable.

For example, if you are using a variable called num_pennies to store the number of pennies, you can prompt the user for the number of pennies as follows:

```printf("Enter the number of pennies: ");
scanf("%i", &num_pennies);
```

Note: When using the scanf function to read values into numeric variables, remember to include the & (ampersand) in front of each variable!

### Integer arithmetic

In C, addition and multiplication are performed using the + and * operators. A chunk of C code that computes a value is called an expression. The + and * operators allow you to construct expressions that perform addition and multiplication, respectively.

For example, if the variable num_quarters contains the number of quarters entered by the user, the C expression

```quarter_total = num_quarters * 25;
```

computes an integer value for the total number of cents for the quarters and stores it in a variable called quarter_total.

### Printing integer values

Once you have computed an integer value, you can print it using the printf function. For example, the C statement

```printf("Amount from quarters: %i cents.\n", quarter_total);
```

prints the value of the quarters. The %i character is a placeholder which is replaced by the value of the variable quarter_total when the message is printed. The \n is a special character that represents a new line, i.e. subsequent output will begin on the next line.

### Testing the program

Run the program and type in several combinations of coins. Make sure the program produces the correct output, including proper formatting of the dollar field.

### Submitting

Submit your solution using the Tools->Submit option (or manually using the procedure described in the Using Marmoset handout).