Help with small simple program

This is a discussion on Help with small simple program within the C Programming forums, part of the General Programming Boards category; *This is not a graded project* Hey guys, I'm doing a small project for my college homework and it requires ...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    2

    Help with small simple program

    *This is not a graded project*

    Hey guys,

    I'm doing a small project for my college homework and it requires me to write a simple program for the following question except I"m late in the course with only small knowledge in C.

    If someone would give us a hand it be great (i dont want the whole thing to be written out for me I'd like to learn as much as I can)

    The question is as follows: "You are asked to write a simple program that will accept an integer value in the range of 5-95 and in increments of 5 at a time, representing the number of cents to give to a customer in their change. The program should calculate how many coins of each denomination and display this to the user. Valid coin values are 50, 20, 10 and 5. Your solution (program and algorithm) should be modular in nature. This requires the submission of a high-level algorithm and suitable decompositions of each step."

    All this requires is a simple notepad code i think using #include <stdio.h> etc. I am able to compile this myself.

    I thought I'd be able to do this but I cant get it started lol. *This is not a graded project*
    Last edited by Sonor; 04-01-2005 at 11:21 PM.

  2. #2
    Registered User
    Join Date
    Apr 2004
    Posts
    173
    Think of the steps on how you want to calculate (i.e. the algorithm) before you jump into the code.

    So let's say I input 70 cents. What can I do to divide them into 50/20/10 and 5 cent coins?

    By integer division.
    70/50 = 1
    The remainder after this is 70%50 = 20
    20/20 = 1
    The remainder after this is 20%20 = 0
    Terminate once you reach 0.

    Likewise, if I input 95 cents:

    95/50 = 1
    95%50 = 45
    45/20 = 2
    45%20 = 5
    5 / 10 = 0
    5 % 10 = 5
    5 / 5 = 1
    5 % 5 = 0

    See the pattern? Hope it gets you started

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    Well step 1 is write the "hello world" program to make sure you can edit code, compile it and run it.

    Then move on to actually solving the problem. My first suggestion is read in a number, then print it out again unchanged.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    Or until someone just hands out the answer without any further effort required
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Apr 2004
    Posts
    173
    Ek, I didn't type out any code only gave some pretty good hints on how to solve the problem
    *Assuming you are referring to me*

  6. #6
    Registered User
    Join Date
    Apr 2005
    Posts
    2
    haha ive done all those hello world programs n stuff i just need help how to get started on solving for what the question asks, and orion did that so appreciate that thankyou!

    now i must turn this into a algorithm then code. thanks for your help guys.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Builder C++ large files support for simple C program
    By Murfury in forum C Programming
    Replies: 3
    Last Post: 11-23-2007, 02:47 PM
  3. want to make this small program...
    By psycho88 in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2005, 01:05 AM
  4. Replies: 5
    Last Post: 11-27-2005, 08:50 PM
  5. Need help with simple, simple program.
    By LightsOut06 in forum C Programming
    Replies: 5
    Last Post: 09-01-2005, 08:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21