Extra Credit 1

Due: April 30, 2024
Points: 100


All programs are to be submitted through Gradescope. Gradescope will compile and execute your program, sometimes with varying inputs or invocations. You can see your score once executions are done. You can submit your program multiple times, up to the deadline — at that point, the score you have will usually be the grade for that problem. I say “usually” because we reserve the right to look at your submission and deduct points if you do not use proper programming style.

You have to name your program as given in the problem. Otherwise you will get an odd error message indicating there is a problem with Gradescope.

Also, your output must match Gradescope’s exactly, including blanks and tabs — so pay attention to the example output!


Take the change.c that you created to answer homework 1, problem 2, and change the output to reflect the following:

  1. If there is exactly 1 quarter, dime, nickel, or penny, your output uses the singular for the coin
  2. If there is more than 1 quarter, dime, nickel, or penny, your output uses the plural for the coin
  3. If there are no quarters, dimes, nickels, or pennies, do not print that coin
  4. If a 0 is entered, print the message “0 cents is nothing” and quit
  5. If a non-integer, is entered, print the error message “Please enter a non-negative integer” on the standard error and quit
  6. If there are two different types of coins, put an “and” between them
  7. If there are three or more types of coins, put a comma after each type of coin except the last, and put an “and” between the last two types of coins.

Here are some examples of inputs and outputs. Input is shown in red, and “” represents a newline. Note that there is a prompt for the input!


Amount? 16↵
16 cents is 1 dime, 1 nickel, and 1 penny

Amount? 15↵
15 cents is 1 dime and 1 nickel

Amount? 1↵
1 cent is 1 penny

Call your program “change2.c”.


UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
ECS 36A, Programming & Problem Solving
Version of April 22, 2024 at 11:29PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh