C :: Find The Least Amount Of Coins Required To Make A Value
Mar 8, 2014
Write a program in C that will allow a user to enter an amount of money, then display the least number of coins and the value of each coin required to make up that amount. The twist to this program is the introduction of a new coin - the jonnie (value = $1.26). Therefore, the coins available for your calculations are: Twonies, Loonies, Jonnies, Quarters, Dimes, Nickels and Pennies. You can assume the amount of money user enters will be less than $100.00.
User enters $4.53. Your output should be:
The least number of coins required to make up $4.53 is 4. The coins needed are:
1 Toonie $2.00
2 Jonnies $2.52
1 Penny $0.01
$4.53
I'm wondering if i'm close. I'm stuck on what to do for the output. This is what i have so far.
Code:
//Start
#include <stdio.h>
int main() {
//Get user input for amount of money
//Input
int i;
//Store input from user
[Code] .....
View 3 Replies
ADVERTISEMENT
Dec 15, 2014
You work for a painting company. Your job is to calculate the amount of paint needed for every contract assigned to the company. This time, you need to paint an outside wall. The dimensions of the wall are 5 X 7m. The window is a circle with the radius of 1m. Write a program that would calculate the following:
The amount of paint needed knowing that you need 1 gallon per 10 square meters. The amount of time to complete the job knowing that it takes 1 hour per 10 square meters to prepare the surface, 5 minute per square meter to pant it and 5 minute per square meter to clean up the area.
View 8 Replies
View Related
Mar 9, 2013
Say I want to leave a program running and it stops when I press F9 for instance, I'm looking for something like (and note this is just a generalization).
#include blah
using namespace std;
/wait 2 hours
/key.press = F9
return 0;
View 5 Replies
View Related
May 14, 2013
How do you find the amount of space in a char array?
View 11 Replies
View Related
Sep 21, 2013
For the program, you will write a utility that converts dollars to coins. It is a simple program that must have the following:
-Multiple outputs to the screen
-At least one input
-The use of integers and strings
-Looking or repetition with Do..While, If..Else
-Must have some output text to show correct value of coins that would be converted from the dollars.
-Code must include comments explaining your reason for the code section or what the code is doing
-Code must compile
-Whole dollars only. If value is less than 1 or 0, the program should break or exit.
-Turn in your source code (.cpp file) to your instructor with your filename including your first and last name and your compiled executable.
View 3 Replies
View Related
Feb 25, 2015
I'm trying to make a program that allows the user to input an arbitrary amount of numbers and finding the largest of all the inputs but I keep having problems with the output.
javascript:tx('
#include <iostream>
using namespace std;
//******************************************
//CLASS COMPARATOR
//******************************************
class comparator {
public:
comparator();
[Code] .....
And regardless of what numbers I enter, I always get the output of 10. Also I got the EOF idea from my textbook so if there is a better way of doing this I'd like to hear it. I don't know any clear ways that looks nice to end the while loop when the user doesn't have any more numbers to enter.
View 3 Replies
View Related
Mar 5, 2013
How do I make a specific character show up a specific amount of times?
Like I am generating a random number then I need to make "|" show up that many times on the screen.
View 1 Replies
View Related
Apr 30, 2013
Code:
void search(){void output(void);
char title[20],;
char *p;
clrscr();
[Code] ......
Info:Program that stores information about reports .the above function searches the report according to its title. list is the name of the structure that stores the records.
Why i'm using strstr:
for eg. there is a report titled 'report on tigers'
I want the report information to be output if someone searches for 'tiger'
Output:displays all the entries i have made till now
file is attached.
View 4 Replies
View Related
Jan 8, 2015
Why is using namespace needed in linux but not in turbo c++?
View 1 Replies
View Related
Sep 5, 2014
I actually am wanting to practice on a 2 dimension char array. so, I am using the below program and getting the error - Lvalue Required For Function Main
#include <stdio.h>
#include <conio.h>
#include <string.h>
char varStringArray[1][5];
int main(void) {
clrscr();
varStringArray[0] = 'a';
printf("%c", varStringArray[0]);
return 0;
}
View 2 Replies
View Related
Jan 9, 2014
Im using the remquo function in the cmath library as follows:
int quotient;
double a = remquo (10.3, 4.5, "ient);
This gives the correct remainder (a = 1.3) and quotient (quotient = 2).
Infact about 50% of the answers are right when I play around, however, trying something like:
int quotient;
double a = remquo (2.25, 1.5, "ient);
yields an incorrect quotient of 2 and remainder of 0.
I do think this has something to do with float arithmetic. I recall tinkering with the float number 0.500 and that the CPU actually saves it as 0.50000000000000231. However if my suspicion of float arithmetic as the suspect is correct, I do not understand why a tenth decimal would make such a drastic difference as changing the quotient result.
View 10 Replies
View Related
Apr 21, 2013
I am getting this error when compiling my program with quincy:
Error: I value required as left operand of assignment
The program is meant to calculate how much parking costs based on the amount of hours in a park and what type of vehicle it is. the error is coming from my function definitions which i have just started to add in.
Code:
float calcCarCost (char vehicletype, int time, float car)
{
if ((time > MINTIME) && (time <= 3))
calcCarCost =( CAR * time );
}
The error is on line 72 which is:
calcCarCost =( Car * time);
I should probably point out CAR is already defined as a constant with a numerical value given and time is previously asked to be input in when the program runs.
View 10 Replies
View Related
May 19, 2013
When i try to compile this code it gives me a error during run-time saying "*program name* has stopped working"
Code:
#include <iostream>
#include <memory>
using std::cout;
using std::endl;
using std::unique_ptr;
[Code] .....
Why is this happening? Also why do you need the asterisk on smart pointers to assign them a value? Is it just because, or is there a reason.
View 5 Replies
View Related
Apr 24, 2013
I have to write a code in which the addition of prime number gives the number user input..
for example if user enters 10 then
7+3 = 10
2+3+5 = 10
View 2 Replies
View Related
May 3, 2014
#include<conio.h>
#include<alloc.h>
#include<string.h>
struct node
[Code]....
View 3 Replies
View Related
Oct 18, 2013
The issue arises with case 3 where it tells produces an error when I attempt to compile and says "lvalue required for left operand of assignment error". How to fix this so that I can properly run the program.
View 5 Replies
View Related
Oct 12, 2013
You enter decimal number into the program and what base you want. The integer part of the decimal is being handled fine, but the decimal is not.
For example, I enter 15.6847 and base 10, which means I'm going from base 10 to base 10. It spits out 68469999999999 for the decimal part. (Do not worry about the first block of numbers. The second block seperated from the first by a space is where the decimal will appear in order.)
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int baseConverter(int, int, int *, int *);
[Code] ....
View 2 Replies
View Related
Jan 1, 2014
I get the following error:
pointers_array.c: In function ‘readlines’:
pointers_array.c:42:37: error: lvalue required as left operand of assignment
I know what the error is saying but what it is giving it with this code:
/* readlines: read input lines */
int readlines(char *lineptr[], int maxlines) {
int len, nlines;
char *p, line[MAXLEN];
nlines = 0;
[Code] ....
View 3 Replies
View Related
Feb 5, 2013
I got above error in my program. My program is socket program. I am using ubuntu 11.10.
#include <netdb.h>
#include <netinet/in.h>
#include <string.h>
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#define PORT 4547
/*int parseARGS(char **args, char *line) {
[Code] ....
View 4 Replies
View Related
Jan 20, 2014
Goal: I want to use cygwin g++ to write DirectX applications.
I know that one of the mingw packages contain directx libraries.
Now that I have installed cygwin, can I use directx also?
BTW, does netbeans open a mingw project using cygwin tool chain?
View 5 Replies
View Related
Apr 21, 2013
Using C#, is it possible to programatically start an application and enter a required user name and password
View 2 Replies
View Related
Mar 6, 2013
I bet there's a simple function that can return the amount of RAM available on the computer, or perhaps the total RAM on the chip.
Basically I want a way of making sure my program never tries to allocate memory when it can't... I know that Windows should stop this happening anyway but I want to make sure the program can take care of certain things if it happens.
View 3 Replies
View Related
Feb 25, 2015
I want define Variable that has all amount of between two integer example: 2-4
View 1 Replies
View Related
Jul 10, 2013
I have written the following code to add data to text files which are required to store 3D scan data (I have to calculate the y-coordinate). My code seems to work except that it stops working when I want to create more than ten text files i.e. the directory I am trying to store them in will not hold any more than ten text files. Code is shown below.
#include <string>
#include <locale>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
[Code] ....
View 1 Replies
View Related
Oct 25, 2014
I'm trying to make a very simple reaction game where a random number flickers on the screen for a fraction of a second and the user has to then enter the number before another comes on the screen after a random amount of time. However I dont know how i would make it so that the user cannot enter anything after a certain amount of time has passed, below is my code?
Also FYI, clock_start is at 5100 because by the time the program actually gets to scanning in the first number the time is at an absolute minimum of 5050 milliseconds however obviously this is an impossible number to reach due to processing, my machine clocks in at 5080.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
int main(void){
[Code]...
View 6 Replies
View Related
Sep 29, 2014
How to write a code that will let me input how many variables I want.
Write a program that will enable you to enter a certain amount of values
Eg. 4
And then add the corresponding integers. Ex.
Choice: 4 12 34 56 78
The sum of the integers is: 180.
View 4 Replies
View Related