Thread: Calculating Engine Purchase

  1. #1
    Registered User
    Join Date
    Feb 2013

    Calculating Engine Purchase

    Hi guys, I am a complete noob when it comes to programming and I have to take this programming class to be able graduate this year.

    I have to write a program that calculates how many boxes and packages one must purchase to get a specific number of engines. The number of engines needed, the cost of a box, and the cost of a package are entered by the user. One box contains 25 engines, and one package contains 3 engines.

    Here is an example output provided by our teacher:

    Enter the number of engines needed: 30
    Enter the cost of a box of 25 engines: 65.95
    Enter the cost of a package of 3 engines: 8.49

    You will need to purchase 1 box and 2 packages of engines at a total cost of $82.93. (program ends)

    I'd like to note that costs of the box and packages are the same for each test case we have to do. Also, when printing out the answer the correct word (box/boxes, package/packages) should appear after the number. And if the number is 0, nothing should be printed.

    I understand how to do the calculations to find out the numbers required, and that I have to use if/else if statements to make the correct word appear after the number. The problem is I have no idea how to make the number appear in the output statement. Also, all the calculated numbers are supposed to be integers.

    Please help if any of this makes sense to you. If you need more clarification, I'd be happy to do so.

    Thank you in advance

  2. #2
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Nice, France
    So, what's the problem? Can't you be more specific than just copy-pasting your exercise?

    -- by GReaper, the Spartan :P
    Code - functions and small libraries I use

    It’s 2014 and I still use printf() for debugging.

    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opinions on laptop purchase
    By xtrmi in forum Tech Board
    Replies: 4
    Last Post: 12-09-2008, 03:29 AM
  2. Problem with the purchase function
    By HAssan in forum C Programming
    Replies: 1
    Last Post: 02-07-2006, 11:03 AM
  3. Question on purchase and change program
    By s_ny33 in forum C Programming
    Replies: 10
    Last Post: 11-07-2005, 04:14 PM
  4. purchase
    By face_master in forum A Brief History of
    Replies: 15
    Last Post: 12-08-2002, 02:17 AM
  5. Your dumbest purchase.
    By Cheeze-It in forum A Brief History of
    Replies: 25
    Last Post: 07-23-2002, 04:24 PM