Write a simple c program that will accept an integer value

Assignment Help C/C++ Programming
Reference no: EM131973925

Assignment

Create a C Program

Question 1

You should read this question as if the change giver is a bank teller who has to give amounts of money to customers but can't count very well so needs you program to help them.

You are asked to write a simple C program that will accept an integer value in the range of 5-95 and as a multiple of 5 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.

Note that for this problem the principle of code reuse is particularly important and a significant number of marks are allocated to this. You should attempt to design your solution such that it consists of a relatively small number of functions that are as general in design as possible and you should have one function in particular that can be reused (called repeatedly) in order to solve the majority of the problem. If you find that you have developed a large number of functions which each perform a similar task (or have a lot of repeated code) then attempt to analyse your design to generalise the logic so that it may be reused.

Question 2

You are to extend your solution to Question 1 above by allowing the user to enter the amount of change as dollars and cents as a double (real number). Valid dollar values are 100, 50, 20, 10, 5, 2 and 1. You program should output the correct combination of dollar and cent denominations required and should be able to work for any valid dollar amounts. Cents amounts may be should be multiples of 5 as in the previous question.

In this question you will need to explicitly convert a double to an integer to break the inputted double down to its component parts as integers. You can use the following code as the basis for doing this:

float change;
int dollar, cents;

...

dollar = (int) change;
cents = (int) (((change - dollar)*100) + 0.5);

Again your solution for this problem should be modular.

Reference no: EM131973925

Questions Cloud

Offensive stockpile of vulnerabilities : 1. What is a key practical technique to reducing the offensive stockpile of vulnerabilities besides hiring more security researchers:
Write routines makeunion and intersect that return the union : Write routines makeUnion and intersect that return the union and intersection of two sorted linked list. (basiclinked list).
How quickly should that state machine cycle : How quickly should that state machine cycle through the digits so that the digits don't appear to blink? Research persistence of vision if you need more informa
What is the sql query entry for problem : What is the SQL Query Entry for this problem: Sy would like to know which stores have more than one truck.
Write a simple c program that will accept an integer value : Write a simple C program that will accept an integer value in the range of 5-95 and as a multiple of 5 representing the number of cents to give to a customer.
Examine your eating and drinking habits for three days : You will examine your eating and drinking habits for three days. Try to select days that represent a typical day of eating and drinking for you
Workforce skill and availability : Explain why it may be more efficient for a company to utilize an RDBMS based on workforce skill and availability.
Topic materials or relevant industry examples : Justify your ideas with support from the Topic Materials or relevant industry examples.
Prepare a procedure named bitwisemultiply : Prepare a procedure named BitwiseMultiply that multiplies any unsinged 32-bit integer by EAX, using only sifting and addition.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd