Questions tagged [cash]

Cash problem in pset1

Filter by
Sorted by
Tagged with
0
votes
1answer
26 views

pset 1 - cash problem - No errors, am rounding, but still not always correct amount of coins

I'm having trouble finding out where the problem with my code is on the Cash problem in the CS50 problem set 1. In the other questions for this problem on this forum it often seems to be the round() ...
0
votes
1answer
16 views

Why doesn't my code give me an output?

So I am very new to CS and I have been working hard twisting this code around in my mind trying to figure out why nothing happens when I run the program. It compiles fine, but whenever I put in any ...
0
votes
1answer
26 views

Coin count off by 1 in cash

When I input an amount into the program cash, it gives me one more coin than I should have and I'm not sure how to fix it #include <stdio.h> #include <cs50.h> #include <math.h> //...
0
votes
1answer
35 views

PSET1 Cash - less comfortable - errors only for 0.41, 0.15

I hope you can help me with the PSET1 task - cash - less comfortable. Here is my code but I cannot figure out why - when testing the code - only 0.41 and 0.15 deliver wrong outputs (8 instead of 4 and ...
0
votes
1answer
13 views

My program doesn't run when i close the condition's range. When i leave the range open it does't give the answer i want

#include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float change; int cents = 0, coin_number = 0, quart = 25, dime = 10, nickel = 5, penny = 1; //...
0
votes
1answer
42 views

This is my code for cash

This is my code for cash idk what I did wrong cuz when I compile it, it gives me a decimal of the number I put in instead of a whole number representing how many coins. Idk what I did wrong. #include &...
0
votes
1answer
38 views

cash less comfortable

I've been working on my cash problem but it keeps giving me error on the code especially the variables and I don't know why.
1
vote
1answer
19 views

Output Problem on CS50's Cash

so I used check50 on my code and it said 1.6, 23, and 4.2 had a wrong output. Can you please help me to see what I am doing wrong? Here is my code: #include <cs50.h> #include <stdio.h> #...
0
votes
1answer
31 views

Improvement in Cash Code

im curently doing pset4, but redoing the psets one by one for practice since I feel like im not yet ready to make pset4. Just finished pset2, Cash. The code is right and works, i was just wondering if ...
0
votes
2answers
78 views

Incorrect output by check50

I worked very hard on Cash and finally produced compilable code and correct output. But when I ran check50 I got these results, shown here. Please help. My code is shown below, in case you need it. #...
0
votes
0answers
46 views

Error: more '%' conversions than data arguments

#include <cs50.h> #include<math.h> #include<stdio.h> int main(void) { int n = 0; do { n = (get_float("Change owed: ") * 100); } while (n < 0); int ...
0
votes
1answer
43 views

Cash.c:11:24: error: expected expression

#include <cs50.h> #include<math.h> int main(void) { int n = 0; do { n = (get_float("Change owed: ") * 100); } while (n < 0); int q = ((n / 25) %) ...
0
votes
2answers
37 views

Error: Use of undeclared identifier in cash.c

#include <cs50.h> #include<math.h> int main(void) { do { int f = round(get_float("Change owed: ") * 100); } while (f < 0) q = ((f / 25)%) ...
0
votes
2answers
44 views

PSET 1 Cash two inputs don't get appropriate value

I'm stuck trying to understand what's wrong with my code... When I check it I get this error message: :( input of 1.6 yields output of 7 expected exit code 0, not 1 But getting 7 coins for 1.6$ ...
0
votes
1answer
72 views

Pset1 Cash - Incorrect number of coins

I've put together a solution to the problem set Cash using division. When I run the program, it returns incorrect number of coins for most of the cases, e.g. change 61 - 244 coins, change 0.80 - 14 ...
0
votes
1answer
43 views

Beginner with Cash code problem

Can you please look at my code and tell me if I am close or where to go to get help. I get an error at the G in this line. change= get_positive_float("Change owed: \n"); include include include ...
0
votes
1answer
62 views

problem set 1 _ cash

The problem is that it works for some values and not for others even though the float value is rounded. pls help { float change; do { change = get_float("change: "); } while (...
0
votes
1answer
51 views

pset1 Cash question

For some reason sometimes it gets the answers right and others it gets the answer wrong, I'm stuck so I don't know what to do next. #include <stdio.h> #include <cs50.h> #include <math....
0
votes
0answers
40 views

pset1 Cash, keeps answering 1

#include <cs50.h> #include <stdio.h> #include <math.h> int main(void) { float change; int coins = 0; do { change = get_float("Change owed: "); } ...
0
votes
1answer
29 views

i am working on problem set1 Cash. “else if” is not working

everything is working fine until the condition of remainder <= 5 is met (else if) then it just executes the first part only (if). #include <stdio.h> #include <math.h> #include <cs50....
0
votes
1answer
97 views

CS50 pset 1 cash problem: keep getting 1 as answer

I'm trying to do the CS50 cash problem and the answer keeps getting number 1 no matter which change I input. It won't accept negative numbers as asked by the problem, but I don't know why it doesn't ...
0
votes
1answer
61 views

I am not getting the correct output on pset1 cash… Can someone please look at my code?

#include <stdio.h> #include <cs50.h> int main(void) { float change; int coins = 0; do { change = get_float("Change owed: "); } while (change < 0); int c = change * 100; while (...
0
votes
2answers
61 views

Pset1 cash answer incorrect

//I don't understand why answer shows incorrect include <stdio.h> include <cs50.h> include <math.h> int main(void) { { double n; int c=0; do { n=get_double(&...
0
votes
1answer
36 views

PSET1 One input doesn't give the appropriate output

My current code checks out all the input values except for the integer value of 23. I'm not sure why, and the value is pretty close, 94, instead of 92. But what makes me truly confused is that other ...
0
votes
1answer
114 views

Stuck on CASH problem pset1

I need help on why this is happening: I'm currently doing the cash problem. I used get_float to get user's amount and then used round(amount_from_user * 100) to convert the float to int (i.e cent) as ...
0
votes
1answer
52 views

(pset1 cash) getting correct answer in terminal output, but check50 shows wrong output

After I submitted my cash pset1, it returned three test cases(input of 1.6,23 and 4.2) giving the wrong output(7,92,18), also detailed in check50. But when I try the three test cases with my code, my ...
0
votes
1answer
82 views

Pset 1 .cash weird expected output

I finally managed to come up with something like this. I believe it works just fine but when the machine checks it, all the answers are wrong. E.g. when you are owed 0.41 you should get one from each ...
0
votes
1answer
338 views

Pset 1: Cash help

I've put together my answer for the cash problem set, but when I run the program and enter an amount for "change owed" it always outputs 1. Being new to all of this, I'm not sure what I'm doing wrong ...
0
votes
1answer
75 views

I need help with cash - again

Ok so this is my improved code: #include <stdio.h> #include <cs50.h> #include <math.h> int main (void) { float c; int a, n=0; do { c = get_float("Change: "); } while (...
0
votes
1answer
88 views

I need help. (pset 1 - cash) I don't get this!

So this is the code I have now: #include <stdio.h> #include <cs50.h> #include <math.h> int main (void) { float c; int i; do { c = get_float("Change: "); } while (c <...
0
votes
1answer
51 views

I don't understand where I went wrong?

So this is the code I have right now for cash in problem set 1. I don't know whats wrong. #include <stdio.h> #include <cs50.h> #include <math.h> int maid (void) { float c; ...
0
votes
1answer
24 views

Transform function into a loop or similar

So my problem is in problem set 1 of week 1 of the CS50 Harvard course. The task was writing a program that calculates the smallest amount of coins possible when getting change. I've already written ...
0
votes
1answer
184 views

pset1 Cash: Having a hard time understanding the flow of the app

I wrote this following code as solution to the pset1 cash problem, it compiles and runs but once the user inputs the owed amount it replies with 0 coins to give back, which is false. #include <...
0
votes
2answers
78 views

Problem Set 1, Cash: maths issues

I have been trying to fix this code for the last day, and still can't work out where I am going wrong. Can anyone point me in the right direction please? Thanks in advance! int main(void) { // ...
1
vote
1answer
139 views

pset 1 cash get_positive_float not functioning as intended

I wanted to get the positive float using the get_positive_float function, which I declared later. However, it either accepts -0.99999 or rejects 0.999999. The code looks as follows: #include <...
0
votes
1answer
513 views

pset 1 Cash Question: runtime error: signed integer overflow problem

I am very new to coding and I can't seem to understand what is causing the runtime error: signed integer overflow. My code runs and allows me to enter a change amount when prompted, but fails after ...
0
votes
1answer
129 views

PSet1 cash, modulo problem

Why does this give 19 instead of 20 when change = 4.2? Thanks.
0
votes
3answers
6k views

Problem with pset 1, cash

I get the correct answer for some values, i get the wrong answer for others. I didn't convert my change to cents because I figured I could just keep all my cents, dimes, quarters in decimal values too....
0
votes
1answer
58 views

set1/cash (or greedy)/ Floating point imprecision and rounding requirement help

I think I have figured out a way to convert the users input from dollars to cents. I used the eprintf function and it works. However, when re-watching Zamyla's walk through she mentions towards the ...
0
votes
1answer
201 views

Pset1 Cash Understanding modulo operator and while loops

I'm trying to set up my solution to the Cash problem using modulo. The input seems to be working correctly so far. It only accepts positive numbers through the do..while loop. The problem I think I ...
0
votes
3answers
102 views

Incorrect input of value yields incorect output in Cash task at PSet 1

My code #include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { float sum; int sumInt; // Check user input and convert it to cents do { //eprintf("about to ...
0
votes
1answer
182 views

Error: greedy cash input of 0.41 yields output of 4

I'm getting an error and I can't figure out the solution to this problem. I get an error at check cs50: "input of 0.41 yields output of 4; expected "4\n", not "You typed: 0.41..." Here is my code: #...
0
votes
1answer
218 views

Trying to make cash.c from pset 1 without mod

So I've made this program with modulus and it made sense to me, but when I ran it I got an error message saying I can't use mod on floats. Since then I've been trying to replace this: change = ...
0
votes
1answer
149 views

Week 1 cash.c assignment: How can I get a variable to mutate as it gets operated on?

the way my code works is to reduce c as we count out coin-types. But I'm getting errors. #include <cs50.h> #include <stdio.h> int main(void) { float c; do { ...
1
vote
2answers
188 views

I can´t get (pset1) greedy/cash.c pennies to work properly!

i´ve been trying to figure out what is wrong with my code for the pset1 cash or greedy program, i know about float imprecision but when i print the last value for "ch" it prints .01000, thus meaning ...
1
vote
1answer
95 views

PSet1 Cash returning implicitly declaring library function 'roundf' with type 'float (float)'

I am currently working on the pset1 greedy (cash) project. I am so close to finishing and I only have one more thing to complete before I can submit it as correct. I am working on rounding the initial ...
1
vote
1answer
774 views

Problem with rounding for pset 1 cash

Desperately need help for pset 1 cash! My code failed 2 of the check50 tests: :( input of 23 yields output of 92 :( input of 4.2 yields output of 18 I believe it's a rounding problem, but I've been ...
0
votes
1answer
598 views

Stumped on pset1 cash.c, please help me learn

I'm trying to create a solution for pset1 cash.c, the code below is not meant to be the final implantation, just a cursor to figure out the problem. When I run this code it works for values .01 to .05 ...
0
votes
1answer
747 views

pset7 (buy): what does “SELECT cash FROM users WHERE id = 1” do?

In the pset7 Walkthrough (buy): db.execute("SELECT cash FROM users WHERE id = 1") Where does this "id = 1" come from ? This, makes better sense to me: db.execute("SELECT cash from users WHERE id = ...
1
vote
1answer
29 views

what should i do to make my file run?

~/workspace/pset1/cash/ $ make cash make: *** No rule to make target `cash'. Stop. ~/workspace/pset1/cash/ $ cd pset1 bash: cd: pset1: No such file or directory