We have to ask the user to select either a Visa card type or Mastercard type. Then, we must ask the user to enter the 16 digit card number and determine if the card is valid or not using module 10. If the answer is zero then it is a valid Visa card and if the answer is zero the answer is a valid MasterCard. My problem is that the I have not separated the validation for MasterCard separate from visa.
Here is what I have so far:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main() {
I have written the below but I get an error when I run it. I get the below error.
$mcs main.cs -out:demo.exe 2>&1
main.cs(93,58): warning CS0162: Unreachable code detected main.cs(85,21): error CS0161: `CreditCards.CreditCardsValidator.LuhnCheckPerformed(string)': not all code paths return a value Compilation failed: 1 error(s), 1 warnings
The code is below: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; /**@return a Credit Card Validation Application
So I am writing an assignment to Detect prime numbers and it works by Asking for how many values you are going to enter, and then saying "Enter value 1: "
Then you would input and it would calculate via for loop, and that part is working. However to make my program more foolproof, I devised a way for the user to be unable to "Break" the program by inputting characters or float values. Here is the code for that:
while(!(cin >> num)){ //num is some type (char, float, int etc.) cout << "That is not at valid input, please try again" << endl; //"Error Message" cin.clear(); cin.ignore(10000, ' '); //Clear and reset cin cout << "Enter value " << n << ": "; //Re-Prompt User for input //n is whatever value the for loop is on }
and this code works fine, I was just curious about how i would turn it into a function. Preferably wiht the name: ValidateInput(Param1, Param2);
The Parameters of the function preferably would be the variable youre inputting and the message you want to prompt. So somehow i wish to have it so for the above example it would look like:
ValidateInput(num, "Enter Value " << n << ": ");
But I don't know exactly how to label either parameter part because I want it to work for chars, ints, floats etc. And I don't know what I want it to return if anything either.
I'm making a flash card type console application using visual studios 2013. The flash cards contain character that I can display using unicode. So far I am looking at about 200 characters across 2 unicode blocks which I don't want to hard code into my arrays. I thought of initializing my arrays using a loop. The only problem is I don't know how to add in hexadecimal. So is there a way to initialize my array without having to input 200 values my self? Also is hexadecimal addition possible without me having to write a function for it?
I'm trying to make a selection process using roulette wheel selection. To do this I created two matrix, one random probabilities and one increasing probabilities. The idea is to choose a number according to the random probabilities. Here is the code I've written.
#include <iostream> #include <conio.h> #include <cstdlib> using namespace std; int main (){ float select [5], prob [10], mat [5]; int c, r, z; cout.precision (2); cout << "Random Number:" << endl;
[Code]...
The result I got is as follows:
Random Number:
0.0013 0.56 0.19 0.81 0.59
Increasing Probabilities:
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Selected Column: 0 5 6 8 9
The evaluation doesnt seem to start from c=0 again. The selected column should be 0, 5, 1, 8, 5.
The deck of cards so it is populated with all 52 cards. Once you have populated the deck, you need to shuffle the deck. Here is a simple algorithm you might consider for this purpose:
For each card up to the middle of the deck generate a random number modulus the size of the deck, swap the current card with the card at that location done
To implement this requirement you need to implement and use the following functions:
i was reading trying to get it how to display the out put, all i got to is how to declare the arrays. How to start it also i saw some examples have " struct card"
I have to develop an application named smart client score board in c#
Main requirements for this application are that application should display the live scores, detailed score board, running commentary (in text), players and team profiles, statistics of matches, results and fixtures for cricket.
sort out websites which support rss feeds for full score card.
I want to get or view the SIM card number from the dongle (the dongle will b already connected to the computer where the SIM card will be inserted into it) but the coding should be done by C programming / Language.
I found a card shuffling function on a long dead thread.
Code: for (int x = 52; x > 0 ; x--) { y = rand() % x; temp = deck[x]; deck[x] = deck[y]; deck[y] = temp; }
I do not understand how numbers are not repeated in the function. It seems like it would be possible to get 2 cards with the same number with the above function.
I also am getting incorrect numbers. It seems like I should only get numbers between 1 and 52 (which is what I want). However, I am getting the number 0, and some number between 1 and 52 will be missing, but I will have a total of 52 unique numbers.
I played around with using 51 instead of 52, x > 1, and changed to --x and none of those produced the desired results.
I'm writing a card game and I'm having trouble getting the first part of it right, which is picking out a random card from the deck and displaying it to screen. So it's supposed to display a different card every time i run the function in the program. The problem is, I keep getting the same output every time "Nine of Hearts".
This is what I have so far,
#include <iostream> using namespace std; //declare two string arrays //one holds the "suit" of the cards, the other hold the "value" string suit[] = {"Diamonds", "Hearts", "Spades", "Clubs"}; string faceValue[] = {"Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ace", "King", "Queen", "Jack"};
[Code] ......
This is the output I keep getting every time I run the program:
Nine of Hearts
This "random selection" function I'm trying to do is meant to work as a means of shuffling the cards in the beginning of every round in the game and displaying only the top card from the deck.
I almost finished a program but am stuck on sorting the hand im dealing with qsort. sorting by the face values and if they have the same faces im suppose to follow this suit order to determine which one is greater (Clubs, Diamond, Hearts, and Spades) how would i adjust my comparator function to do this for me ?
My specific request is for retrieving values that are stored to a CompactFlash card. I am able to store values (we call them recipes) to the CompactFlash card as .csv file. I just haven't been able to figure out the code to retrieve this information back to the touchscreen.
Code: // Create a new folder if it doesn't exist CreateDirectory("/recipes"); //Create the file if it doesn't exist CreateFile("/recipes/recipe.csv"); //open the file hfile = OpenFile("/recipes/recipe.csv", 2);
[Code]....
Now with that said, I would like to retrieve these values from the .csv file.
The doubt is. I have a test_xpm function and I need to call this char array but this is so many pointers that I can't even figure out where I'm pointed to (?)
Code: int test_xpm(unsigned short xi, unsigned short yi, char *xpm[])
I tried something like read_xpm(xi, yi, *xpm[0]); but I'm guessing I need to index that array and run all those chars in order to show them.
I am struggling to finish up my game of War. There are a few problems I have ran in to. My shuffle function seems to work fine. I believe my problem lies within my game rules. When I run my code, the game usually plays all the way through but almost always ends in 'War'. I am struggling to get the game to restart after running once. I am not sure how to clear the list and start over.
I'm writing a program with two classes, one that contains a card's rank and suit and the other contains pile of these cards. I'm having trouble when it comes to adding a pile to another pile...here's what I have so far:
class Card //Card class declaration { private: int rank; //invoking rank char suit; //invoking suit public: void setCard(int r,char s); //determines card suit/rank
[Code] ....
I understand that I'm calling my pile arrays incorrectly, but I'm not sure why.
This is a playing card deck creator and shuffler i made yesterday. It is very simple now, but i believe that it could easily be implemented into a card game program of some sort.
I'm doing a card game and i'm unclear on how to retrieve the card by doing vectors. after i use use srand() in main and create a rand() in a function, how can i retrieve that random card 1-52?
so far i know that i have to find the length of the card. but i don't know why i have to save the location onto another variable and erase the card of the specified index before returning the card out the function.
int location = rand() % cards.size();
I don't know why i need to do this and how do i reinitialize the variable cards into another variable?
Consider a program that simulates a card game, with multiple player hands and a deck to draw from. Each hand can use an array to represent the cards it contains; sometimes it is useful to also declare an additional variable for each hand (or deck) indicating exactly how many cards are present.
1) Describe a simple function that would manipulate both the array representing a hand and the number indicating the size of the hand.
2) Describe a simple function that might be able to manipulate the array without referring to the hand size variable at all.
3) Generally, if the array was passed as a parameter to a function, how often would the hand size be included as a parameter?
I am having a problem with my "void Validation :: getId()" function its suppose to get the id number from the user but when I try and type a letter to see if it catches it, it goes into this continuous loop. Also with my "string Validation :: getName(string name)" function it suppose to catch the comma in the user input for their last name , first name but doesn't catch it and still returns the name back to main function.
#include "InputValidation.h" #include <iostream> using namespace std; Validation :: Validation() { name = " "; id = 0;