C++ :: Read (three Digit) Integer Representing Value To Be Encrypted
Nov 3, 2013
I have been working on some C++ code that doesn't seem to be going right. I'm wanting it to read a (three-digit) integer representing the value to be encrypted, a (one-digit) integer representing the encryption key, encrypt the value and print the encrypted value. The encrypting method used is that each digit in the given number is replaced by ((the sum of that digit plus key) modulo 10) then the first and last “encrypted” digits are swapped.
For example, if the number entered was 216 and the key given was 7, after applying the encryption procedure described the first digit (2) would become 9, the middle digit (1) would become 8 and the last digit (6) would become 3. The first and last encrypted digits are then swapped. The program displays the encrypted number: that is 389 in this case.
#include <iostream>
using namespace std;
int main() {
int isolateDigits();
int replaceDigits();
int swapDigit1withDigit3();
[Code] ....
View 1 Replies
ADVERTISEMENT
Oct 22, 2014
The problem states that i need to accept any pin number between "00000" and "99999". I need to read the PIN the user enters as an integer. The problem is that if the PIN is read as an integer, the PIN "01111" will be "1111" which is invalid and the pin "00001" would be read as "1" which is also invalid. How would I go about fixing this problem for PIN numbers that start with a "0"? Again I cannot read the PIN as a char array or string.
View 2 Replies
View Related
Sep 27, 2013
I need to be able to actually read my encrypted file..
I have the decryption code and works perfectly when running it through console app c++.
But, the way I decrypt is to decrypt from a file, and create a new file which is decrypted.
I can't use that kind of code in my program in windows form app c++..
I need to read the encrypted text file and decrypt it in memory while using it for my program..
Some links to my codes I use at the moment.
My decryption coded in console application: [URL] ....
My decryption code edited for form application (Did not do anything) [URL] ....
And this is the code I tried to read after it got decrypted (Reading file written in combobox_selectedindexchange: [URL] ....
View 2 Replies
View Related
Oct 19, 2013
this code :
#include <cstdlib>
#include <iostream>
#define TRUE 1
#define FALSE 0
using namespace std;
typedef int Bool;
[Code] ....
Gives repeated digits in an integer but only in one condition : Only if the repeated digit is the result of n%10 where n is the integer the user writes. If the repeated digit is not the result of n%10 , then the compiler gives a wrong result.
so the question is : how to make this code gives the repeated digit in an integer (regardless the fact that the repeated digit is the result of n%10 or not and especially with making the minimum of changes on the code)????????? ?????
View 3 Replies
View Related
Mar 15, 2013
Assignment: Take an integer keyed in from the terminal and extract and display each digit of the integer in English. Ex. 932 --> nine three two
Code:
/*This program takes an integer keyed in from the terminal and extracts and displays each digit of the integer in English.*/
#include<stdio.h>
int main(void)
{
//DECLARE VARIABLES
int num;
}
[code]....
I don't know how the program works if the integer is more than one digit.
View 1 Replies
View Related
Mar 20, 2014
I need to create a program that lists off each digit of an integer and then display the sum off all the digits in that integer. I know that sepereatly the sum function i wrote works. But the first part which i try to list off the digits work but in reverse order which i dont know how to correct. and for some reason that i cant figure out this is affecting the sum output.
#include <iostream>
using namespace std;
int digcount (int x) {;
[Code]....
View 5 Replies
View Related
Oct 10, 2014
Return the digit at the user specified index of an integer. If the integer has n digits and the index is NOT in the range 0 <=index <n return -1 Start the digit numbering at 0. Example, if user input is 4 (index) and the integer equals 123456790 the return value for the function is 5 (start index at 0) ; if user input is 40 (index) and the integer equals 123456790 the return value for the function is -1
#include <iostream>
#include <istream>
#include <cstdlib>
#include <cassert>
#include <string>
using namespace std;
int getIndex(int, int);
[Code] .....
View 4 Replies
View Related
Jul 13, 2014
convert a positive integer code into its english name equivalent for digit. A valid code is of size between four (4) to six (6) digits inclusive. A zero is not allowed in the code.
example : if the input is 234056 the output is : INVALID CODE (PRESENCE OF ZERO)
if the input is 23456 the output is : TWO THREE FOUR FIVE SIX
if the input is 9349 the output is : NINE THREE FOUR NINE
if the input is 245 the output is : INVALID CODE (3 DIGITS)
if the input is 2344567 the output is : INVALID CODE (7 DIGITS)
step 1 : input code
step 2 : count the number of digits in the code
step 3 : if there is a zero in the code, "INVALID CODE (PRESENCE OF ZERO)" go to step 4
step 4 : if number of digits is mode or equal than 4 and less or equal than 6, go to step 5 else display the following message "INVALID CODE (<number of digits> DIGITS)
step 5 : call a function called digit_name to convert each digit into its
equivalent english name. display the result
step 6 : print the digits in reverse order
eg; if input is 13453, reverse order is 35431
View 8 Replies
View Related
Feb 18, 2015
Code:
int exploder(int number,int array[]) {
int functi = 0;
int digit = number % 10;
while (number > 0) {
[Code] ....
View 2 Replies
View Related
Apr 24, 2014
I'm new to C programming and in my first computer science class. Our assignment was to write a program that displays each digit of an integer in English. I wrote the following but cannot figure out why it won't display zeros. When I execute and type in the number 1,000, I get "zero."
Code:
#include <stdio.h>
int main (void)
{
int x, y = 0;
printf ("This program displays each digit of an integer in English.
[Code] ....
View 5 Replies
View Related
Jan 23, 2015
I'm trying to create a program that takes an integer input and displays each digit on a new line from right to left.
An example of this would be:
Enter an integer: 657
Digit (1): 7
Digit (2): 5
Digit (3): 6
So far I have this:
#include <stdio.h>
#include <math.h>
int main() {
int i, input, output;
printf("Enter an integer: ");
scanf("%d", &input);
if(input == 0)
printf("Digit (1): 0");
[Code] ....
It works perfectly fine, but I just learned that I am not allowed to use the #include <math.h> so I have to take out floor, log, and pow.
I'm pretty sure I have to do some sort of while or for loop to get the results, but how to do it.
View 6 Replies
View Related
Oct 26, 2014
Write a function which will take 3 arguments. The function needs to return a new number which is formed by replacing the digit on a given position in the number with a digit which is carried as an argument (the position in the number is counted from right to left, starting with one). Write a main program which will print the newly formed number.
Examples:
A function call of 2376, 3 and 5 should return the number 2576
A function call of 123456, 4 and 9 should return the number 129456
What I succeeded to do so far:
Figure out the logic for swapping the digit and write working code for it (in the main function).
What I failed to do so far:
Write a function which will return the desired result.
What is my problem:
I tried writing a function to do this, but as you see from my calculations, my result is divided in 3 parts. I don't know how to return more variables from a function.
Code:
#include <stdio.h>
int main() {
int inputNumber, swapPosition, swapDigit;
scanf("%d%d%d", &inputNumber, &swapPosition, &swapDigit);
int i, numberPart1 = inputNumber;
for (i = 1; i <= swapPosition; i++)
[Code] ...
View 8 Replies
View Related
Dec 24, 2013
I'm trying to make a space shooter and I want to make the code very reusable. So far I've been making a bunch of objects with multiple inheritance like this:
entity: anything which can be drawn, has a position and an orientation
solid: any entity which can collide with something else
mobile: any entity which can move
spriteEntity : an entity drawn using a sprite
vertexEntity : an entity drawn out of vertexes
The entity class has the virtual method draw, which gets defined by either spriteEntity or vertexEntity. mobile and solid virtually inherit from the entity class.
Then I could create a projectile class which inherits from solid and mobile but adds methods to damage stuff it collides with, and multiple subclasses which inherit from both projectile and spriteEntity... But I'm not sure if it's a good idea to go this deep in multiple inheritance for game objects. I know MI has a bad reputation.
I know that some objects of the game will be sprites and some will be vertexes, and I also know there will be stuff which collides and doesn't move... Or should I make the mobile class a subtype of solid?
View 6 Replies
View Related
Apr 6, 2013
how to use 3 variables to represent a rectangle in a grid instead of using 4. The traditional way is to use (x,y) (x2,y2). I propose using (x,l,h).In the traditional way as you probably know, (x,y) is the left op most corner, and (x2,y2) is the bottom right most corner. In the way I am proposing X is the left side, l is the length of the top side, and also the length of the bottom. 'h' is the height of the left and right. I think it's obvious how these three can define a rectangle same as the four.
View 2 Replies
View Related
Oct 15, 2013
How do I read integers to a string and store then into a vector array?
I need to add two input digits i.e. "1234567878887777" and "123344543543543"
View 8 Replies
View Related
Mar 18, 2015
We are supposed to create a point structure that can be used to represent a point in the xy-plane. Then, write a menu-driven C++ program that uses variables of type point to perform a variety of tasks involving points in the xy plane, including slope, distance, midpoint, equation of a line passing through points, and colinearity. One of the functions we are to create is simply for reading in the user-input in the following form "(x,y)" with the user entering the parentheses and comma. We are to create two functions that translate back and forth between this format and what the assignment calls "one point variable."
I'm confused how I'm supposed to take the user entering, say "(1,4)" and reading that into an x and y, and then comparing it against another set of points. I'm guessing I read them in as a, b, c, d, but I'm not sure what this has to do with a structure.
View 1 Replies
View Related
Apr 3, 2015
I have an application which needs to connect to a database. It runs in the background so there is no user input. I therefore need to store the connection string. I want to encrypt the connection details and then store the encrypted information. My thinking is I would read the encrypted details, from wherever I store them, unencrypt them and then connect to my database.
I've done a bit of reading on this and the SHA1CryptoServiceProvider method seems like an option but it appears that this cannot be unencrypted.
So how can I use this encrypted information?
Or is there another method?
View 1 Replies
View Related
Oct 16, 2014
this program is not giving to chance to enter the ooplevel value.
Code:
#include <iostream>
using namespace std;
const int SLEN = 30;
struct student {
char fullname[SLEN];
char hobby[SLEN];
int ooplevel;
};
// getinfo() has two arguments: a pointer to the first element of
// an array of student structures and an int representing the
[Code]...
View 3 Replies
View Related
Feb 13, 2014
how to carry out the conversions. The assignment is the normal hex to octal and Quart (base 4) via bit munipulation which I have worked out myself. However, I have been trying all day to figure out how to read in a string such as H1234, or O4567. How to parse the input I can handle the remainder myself. I'm just stuck and I've tried for hours.
View 5 Replies
View Related
Mar 14, 2014
I read one csv file in which it contains different types of data like string, integer etc.I want to fetch only integer data from that file and store in vector.Below i copy some code that read line from file,store in vector.I tried to convert string to integer or double and do some operations on it as i know that string values,but how to identify only integer values and store that in vector?
#include<iostream>
#include<vector>
#include<string>
#include<fstream>
#include<sstream>
#include<iterator>
#include<algorithm>
using namespace std;
int main() {
string line;
int cnt=0,val1,val2;
[Code] ....
input file like
Employee Code:121AEmployee Name :David
DateInTimeOutTimeShiftTotal DurationStatus
01-Apr-139:5919:53FS 9:53 Present
View 1 Replies
View Related
Mar 24, 2013
Create a class representing project activities. In this class include all the required data members and member functions. Each activity should have a record of activity duration, calculated early start, early finish, late start, late finish, free float, and total float. Each activity may or may not maintain a list of its successors and predecessors. Provide your design in UML and implement it in C++ using an interface head file and an implementation source file. I do not understand classes or UML designs.
View 2 Replies
View Related
Sep 24, 2013
So basically I have an array of hex numbers representing a binary number. Each binary number is 1/5th layer of the over all font.
For example... the letter A
........ B00000000 0x00
.****... B01111000 0x78
...*.*.. B00010100 0x14
...*..*. B00010010 0x12
...*.*.. B00010100 0x14
.****... B01111000 0x78
........ B00000000 0x00
As you can see each HEX number is a layer in the font which consists of in the above example 7 layers.
Now what I would like to do is create a C++ program, so I can visualize a HEX font array that I got off the internet.
#include <iostream>
using namespace std;
const char font[][5] = {
{0x00,0x00,0x00,0x00,0x00}, // 0x20 32
{0x00,0x00,0x6f,0x00,0x00}, // ! 0x21 33
{0x00,0x07,0x00,0x07,0x00}, // " 0x22 34
{0x14,0x7f,0x14,0x7f,0x14}, // # 0x23 35
[Code]...
Basically I am asking two things. How can I make this display the correct representing letter in the array when a user inputs his own text.
And secondly, how can I output the HEX numbers that is in the array as a binary number.
View 1 Replies
View Related
Feb 5, 2013
How can decrypt the file that the program below encrypt?
// This program encrypts a file
#include<iostream>
#include<fstream>
using namespace std;
int main() {
const int ENCRYPT=10; // amount to add to a chor
const int SIZE= 255; // array size
[Code]...
View 2 Replies
View Related
Jun 19, 2014
I am to use this cipher in which the number x is encrypted
(a and c are known numbers)
Also, what will the decrypt function be? Actually, i need to find the decryption formula...below is the code i tried to test...
char x = 'a';
cout<<x1<<endl<<x2<<endl;
cout<<x1<<endl<<x2<<endl;
View 6 Replies
View Related
Nov 20, 2014
i have an executable that is encrypted; it is made in Visual C++. decrypt it? what i must to look for? I have some kind of files (.req extention) that have the content encoded by password type.
View 2 Replies
View Related
May 23, 2013
I am trying to make my program read an integer until a space, namely ' ', is pressed, and then move on to the next command. However, all my attempts hitherto with both scanf() and getchar() have been to no avail. Every time it proceeds to the next command only upon pressing Enter, which is not quite what I want.
View 3 Replies
View Related