Questions tagged [credit]

The tag has no usage guidance, but it has a tag wiki.

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

PSET6 Credit - checksum not giving the correct number

list1 = list(input("Number: ").strip()) even_count, odd_count, count = 0, 0, 0 # if the length is even if len(list1)%2 == 0: # iterating each number in list for num in list1: ...
0
votes
2answers
31 views

PSET 1 Credit; Sometimes Check50 works and other times it doesn't

Why does Check50 work for certain credit numbers and not others? I ran debug and found that for some credit numbers and not others it may randomly be always one away from a multiple of 10 preventing ...
0
votes
1answer
15 views

Week 1 Credit; Not Creating Variable

I'm starting the week 1 credit problem, however, when trying to set together every second digit it simply does not print. Could you help me identify where I went wrong? Thanks! #include <stdio.h>...
0
votes
1answer
19 views

I keep getting “expected EOF” when I use check50

this is the message identifies 4111111111111113 as INVALID expected EOF, not "INVALID" this is the code #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
0
votes
1answer
16 views

My code is not compiling

my code isn't compiling and i don't understand the error message #include <cs50.h> #include <stdio.h> #include <string.h> #include <stdlib.h> bool checksum(string credit); ...
0
votes
1answer
11 views

When I multiply my array by 2 it doesn't give expected value

Also, please when I try to add "firstnumsum", it doesn't give expected value and I don't know what to do. #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
0
votes
1answer
35 views

i don't know what's wrong with my code. Trying to convert from string to long

INPUT int main(void) { long long cardnumber, calc; string credit[0]; string nonnumeric; //long long calc = card number; int countcardcharacters = 0; long long c; //user input do { credit[0]= ...
0
votes
1answer
20 views

Making code neater: a way to reduce repeated logical operators?

For CS50 pset1 Credit I'm using repeated logical-OR operators (||) to work out the validity and card brand of a credit card number. When I evaluate the style of my code using style50 it says to insert ...
0
votes
1answer
32 views

How do you find the first digit of a long number?

I wrote the following code to try to find the first digit of a long number (this is for the CS50x "Credit" exercise), but it's not working. Any tips? // Conditions and relational operators #...
0
votes
1answer
29 views

ProblemSet1 - Another Credit.c issue - Can't convert the floating value of my variables into an integer value

I was almost finishing my code when I got stuck with a strange problem. I've asked a question a few hours ago and someone answered, so I manage to fix that issue. But unfortunelly I got stuck in ...
0
votes
1answer
17 views

ProblemSet1 - Credit.c - Issues assigning the sum of the numbers on a variable

So I coded the first lines of the Luhn's Algorithm and tried to print the values of some of my variables to be sure they were doing exactly what I want it. For my surprise they weren't. And I were ...
0
votes
2answers
60 views

PSET1 - Credit: Check50 says wrong what should be right

Someone with the same problem? I have a 16 digit number starting with a 4 and my code identifies it correct as VISA\n, but the check50 says it has to be INVALID\n. What could cause this strange ...
0
votes
0answers
68 views

I can't get the Luhn algorithm to run properly in my code

#include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { long long cardnumber = 0; //Prompt the user for the credit card number using get_long do { ...
0
votes
1answer
63 views

Need help (or idea) making the code looks cleaner. (PSET1/CREDIT)

My code passed pset1/credit but I still think the there must be a way to make my code looks cleaner and more impact. If you have any idea please criticize the code. Thank you in advance. #include <...
0
votes
1answer
51 views

HELP ME!! CS50 pset1 credit.c says INVALID but when I debug it says AMEX?

#include <stdio.h> #include <cs50.h> int main(void) { long long cc; //get user input for cc do { cc = get_long_long("Number: "); } while (cc <= 0); /...
0
votes
1answer
43 views

CS50 Credit - again a scope problem

I think I almost finished the credit problem set, however, I have another scope problem. I think it is really simple. After the checksum, the code is not working anymore. If I put extra braces by the ...
0
votes
2answers
78 views

Credit pS1: how to store the seperate digits and store them

Thank you for the answers. I think that I made some steps. The problem now is that I can't store the seperated digits. It only stores the last one in "remain". My other challenge is that seperating ...
0
votes
1answer
19 views

Scope problem - not print the test results

I have trouble with my scope (PS1, credit) I am using two while loops and to test the result, i print results in between. This code does not print the second printf. I think it is a scope problem but ...
0
votes
0answers
65 views

Stuck by problem set Credit, % operator

As a beginner I am stuck in de problem set Credit. Especially the % function is giving me trouble To better understand it, I tried to use the example of programming simplified to get the sum of digits....
0
votes
1answer
54 views

pset6 credit the sum is not end with zero and check count right how

the Luhn’s Algorithm in 378282246310005 = 48 and in 371449635398431 = 76 so how not INVALID it must end with zero so the two number must be INVALID
0
votes
1answer
63 views

Pset 1 Credit - trying to use count to solve the problem but returns 0

I am trying not to use Arrays to solve this problem. However, the answer keeps showing as 0. Can someone pls help to explain? Thanks a lot in advance! Below is the code: I am trying 1. get the ...
0
votes
0answers
26 views

what are questions about my code, the week1 credit assignment

#include <cs50.h> #include <stdio.h> int length(long long n); int lastdigit(long long n); int stay(long long n); int addmutiply(long long n); int odd(long long n); int digit2(long long n);...
0
votes
1answer
26 views

Check50 giving different results from the code I compiled in pset1

For Problem Set 1, I have the code as written below #include <cs50.h> #include <stdio.h> int card_length(long cNo); void luhn_algo(long lacno, int lacnolen); void finalPrint(int cardDet);...
0
votes
1answer
59 views

I am not getting the correct output when i enter David's card number in credit

This is my code: #include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { int x, y, z, p, q, r, d, e; int k = 0; int s = 0; long A; long n = ...
1
vote
1answer
166 views

credit - Why this AMEX and MASTERCARD numbers are considered invalid?

I have compiled my version of credit, anyway check50 throws 2 fails during its check. Lines with numbers where it fails are: :( identifies 369421438430814 as INVALID expected "INVALID\n", not ...
0
votes
1answer
270 views

error: result of comparison against a string literal is unspecified (use strncmp instead) and Check50 showing error on credit problem

I've submitted my credit problem after testing with possible values and everything seems to work just fine as planned, except that I got some errors that certain numbers could not be tested as INVALID ...
0
votes
1answer
52 views

What is probably wrong in this while loop?

I'm getting positive integers from users. I used a do-while loop to check and validate that the user input is: 1. A positive integer. 2. The length (I.e size) is between 13 and 16 digits BUT NOT ...
1
vote
3answers
108 views

Why is this while loop generating errors

I'm trying to get a 15 or 16 digits numbers (integers) from users and then using a do while loop to check if the user entered a valid number, otherwise, they will be re-ask to enter the number. THE ...
0
votes
1answer
34 views

cant figure out whats wrong with my credit code

#include <stdio.h> #include <cs50.h> #include <string.h> int numlength(long num); int main(void) { long num; do { num=get_long("Number :") ; }while(num<0)...
0
votes
1answer
39 views

pset1:credit, multiplication problem

for some reason my program doesn't multiply (card_number % 10) * 2 for example when card_number % 10 = 6 the output is 6 instead of 12. for(int x = 0; card_number != 0; x++) { if (x % ...
0
votes
1answer
239 views

Pset 1: Credit problem - Checksum?

I'm having trouble with the checksum in the #credit problem. I have no clue on how to operate specific digits within the credit card number (specifically, multiplying the digits in the odd positions ...
0
votes
1answer
647 views

Pset6 credit python Problem

I try to convert my Credit Solution from C to Python now. But on Line 19 ( doubleCheck = ccNumber[i] * 2 ) i always get the error "TypeError: 'int' object is not subscriptable"! How can i fix this? ...
0
votes
1answer
80 views

Credit.c works, but not completely?

So I finished credit.c today and was trying out different numbers from the paypal website the course provided and got some unexpected results and don't know what to do with it. When I type in valid ...
0
votes
1answer
58 views

pset1 credit formula to extract digits keeps returning 0 (potential data type issue?)

Below is the block of code that i have issue with. I'm using this method to extract the digits: num[i] = (num % pow(10, i))/pow(10, i-1). The pow1 and pow2 variables print out correctly, but "digit" ...
0
votes
1answer
306 views

Can't use get_long_long();

So somehow I cant use the get_long_long(); function. It lets me declare the variable, but I cant get any user input for it. Here's my code: #include <stdio.h> #include <cs50.h> #include &...
1
vote
2answers
123 views

error at while loop cs50 Pset1 credit

I am getting an error at while loop it says error: '&&' within '||' [-Werror,-Wlogical-op-parentheses] while((credit % 10 >= 0) && (i < 15) || (i < 16)) here is my ...
0
votes
1answer
56 views

Credit.py Invalid Error

For Pset6 Sentimental/Credit, my code keeps showing a result of INVALID\n no matter what is passed in. Debug50 is not working in Python, so I was not able to work through the lines one by one. Any ...
0
votes
1answer
101 views

pset1 - problem with credit ..help plz

I spent so many hours and still can't figure the problem, any guidance would be appreciated.. I checked against all the paypal test numbers and got same response as the staff's execution, though I got ...
0
votes
1answer
101 views

pset1 - credit - if-else statement issue

I have written a (clumsy) solution to the credit pset1. However, the solution only works for "Mastercard" credit card numbers (i.e. 5555555555554444). For "Visa" and "Amex" my code does return the ...
1
vote
1answer
148 views

problem with pset6 python credit

Below is my code: [hidden code] output is: Enter the card number: 378282246310005 firstTwo 37; firstOne 3; cardlen 15 MASTERCARD note: it shows MASTERCARD instead of AmEx..Why?
0
votes
1answer
107 views

PSET1 - Credit Checksum Problem

{ long long l; do { l = get_long_long("Number: "); } while (l < 0); float count = 0; long long m = l; while( m != 0) { m /= 10; count+...
0
votes
1answer
72 views

pset1 credit working only in certain cases

So, this is probably not a good solution of the problem, but I hoped it would at least work, after struggling with it for quite some time. It made me happy to see it worked for the first number I ...
0
votes
1answer
157 views

PSET1 - Credit HELP

I am now working on the first part of credit, and is currently checking the validity of the number given. I separated it into two parts, one where I summed the doubled digits, and one where I summed ...
0
votes
2answers
101 views

pset1: credit keeps printing INVALID for valid card #s

My solution to credit in pset1 compiles without issue but prints INVALID regardless of whether or not the card number is valid. I've attempted to diagnose the problem to no avail. I used string ...
0
votes
1answer
67 views

Pset1 valid visa number as invalid

I built the first part to check whether a number is a valid AMEX number and used the same logic to check for Visa number but the codes don't seem to work as I tried with several valid visa numbers and ...
0
votes
1answer
61 views

What's wrong with my Credit code? works for some and doesn't for the others

#include <stdio.h> #include <cs50.h> #include <math.h> int main(void) { long long cardNumber; char cardNumberStr[16]; char cardNumberArray[16]; int i, numberOfDigits; int sum = 0; ...
0
votes
1answer
231 views

pset1 credit assignment

I assume anyone looking at this question knows the assignment but to recap I need to write a program that will identify different CC#s—AMEX, MC, VISA, or Invalid. Since all these CCs range from 13-16 ...
0
votes
1answer
943 views

pset1 | error: invalid operands to binary expression ('long long *' and 'int')

Here are snippets of my code: long long card = get_long_long(); long long *FindLength = *card; while (FindLength != 0) { FindLength = FindLength / 10; counterCardLength++; } And ...
0
votes
1answer
52 views

Pset1: Error when trying to assign single digits of int variable to array using for loop

I'm currently working on Credit. I'm trying to find the first two digits of the card number using a for loop. I've created an array named firstdigits with two elements. Then I've created a for loop to ...
0
votes
1answer
521 views

How to find the length of a number

I'm working on Credit and am at the point where I have completed all the required calculations on the credit card and now need to find out if the final sum ends in zero or not. I think that in order ...