Hello, I'm in a beginning Java class, and I am lost :( My homework calls for me to write a program that takes an integer (of unknown length) and prints it one digit per line, like: 5 6 9 8 6 4 3 I have been googling this for hours to no avail. The code below is something I tried based on my failed attempts to google the correct method and it is returning 11 errors. I have also tried System.out.println with charAt, and that didn't work for me either. I have the most basic of knowledge and am not …

Member Avatar
Member Avatar
+0 forum 17

I need to find a digit at a specific postion in a number. Example number 652796, user inputs a 4, "2" is displayed. I have the basis for it, but most of the time, the output is incorrect. Not sure what's wrong. #include <iostream> #include <cmath> using std::cout; using std::cin; int main () { int number = 0, digits = 0, position = 0, result = 0; cout << "Enter a number: "; cin >> number; cout << "Enter a digit position:"; cin >> position; if ( 0 == number) { cout << "0"; } while (position-- > 1) { …

Member Avatar
Member Avatar
+0 forum 2

I have a 2 textbox 1 text box is empty . text2 is multine true second text box have some words. text2 text Example : "12345 is my number and 03451234567ddddsfsa somethingis wrong034512345find 03451234567" .............. i want to find 03451234567 11digit number in text box with first 3 or 4 numbers i mean when we type 034 or 0345 in text1 and click command button then find 0345 in text box and select all numeric number means 03451234567 and add to a listbox. Note: when find 0345 and check 11 digits or max . if find max to 11 digits …

Member Avatar
Member Avatar
+0 forum 1

As for my assignment I had to write a program to swap 2 digit number Example:- If user input 12 the swaped number Would be 21. Along with ALgorithm, and a short description on this program(As how will you solve this program or what measure you'll take to get desired results). Please Help..

Member Avatar
Member Avatar
+0 forum 4

Hi everyone... im using C++ Microsoft visual studio and would appreciate if you can help me out here. Ive been trying to do this the whole day ... and canttt figure it outtt PLEASEE HELPPP !! I am a total beginner so sorry if i have very stupid mistakes. #include <iostream> #include <cmath> #include <string> using namespace std; int main() { int odd = 0; int oddsum = 0; int x; int n=0; int oddx2 = 0; string code = "7896550100164702"; // Reversing the code order code = string(code.rbegin(), code.rend()); cout << "The reverse of your code is: " << …

Member Avatar
+0 forum 0

Here's the problem, I was wondering if i am right to assume that when a three-digit input is entered, i.e. 123, then the string 1 will be stored to al, 2 to ah, but i'm not sure where the 3 goes, or if ever it's plain wrong to look at the problem that way. Here's my plan, ask for 3-digit number, access the digits separately, convert to integer, manipulate the digits separately, then check if greater than 100, 175, and so so.

Member Avatar
Member Avatar
+0 forum 5

Hey guys, I need help recognizing multiple digit numbers that are read so that I may push said number into a stack for future evaluation For example: 22 3 + should evaluate to 25 When I input 22 3 +, my output is evaluated to 5 Any help/criticism is welcome Here is what I have so far: [CODE] template <int size> void Stack<size> :: fillStack() { string expression; cout << "Enter a postfix expression and terminate it with a '$': "; getline(cin, expression); int n = expression.length(); for (int i = 0; i < n; i++) { if (!isStackFull()) { …

Member Avatar
Member Avatar
+0 forum 6

Hi forum, I am just wondering how I could just use the last two digits of a four digit year the user inputs. For example, I want to drop the [19] from [1960] and just use the [60] which should be 3C in Hex so the registers would read it. Here is my Data Segment. [CODE] NUMPAR LABEL BYTE MAXLEN DB 5 ;maximum input length ACTLEN DB ? NUMFLD DB 8 DUP(' ') BINFLD DW 0 MULT10 DW 1[/CODE] And here is my code to accept ASCII characters from the user and convert them to digits. The user should input …

Member Avatar
Member Avatar
+0 forum 3

I have a large number of files that begin with numbers (e.g., 10admin_boundary_x) and would like to rename the files so that they do not begin with a digit (e.g., admin_boundary_x). I am working with shapefiles (.shp, .shx, .dbf, etc) and thought a python script could save me some time. I haven't quite figured it out yet, but here is the code I've got so far: [CODE]import os #read in file from the directory for filename in os.listdir("."): f = open(filename, "w") i = True while i: #if filename starts with a digit, lose first index by renaming and #try …

Member Avatar
Member Avatar
+0 forum 6

Hi , I've written following program that takes a four digits integer from user and shows the digits on the screen separately i.e. if user enters 7531, it displays 7,5,3,1 .Any one can tell me how it can be written better and how to display digit in linear order i.e. if user enters 7531, it displays 1,3,5,7 .Thanks [CODE] #include <iostream> using namespace std ; main() { // declare variables int number, digit; // prompt the user for input cout << "Please enter 4-digit number:"; cin >> number; // get the first digit and display it on scree digit = …

Member Avatar
Member Avatar
+0 forum 3

hey guys.. greetings to all please help me regarding my problem i want to find how many times a digit has occurred in a number. for example i have an array which consists of numbers 1011 1022 1033 number of 1's= 5 number of 2's= 2 number of 3's= 2 .. i want to to that .. please help how can i do this.

Member Avatar
Member Avatar
+0 forum 21

Hello. I need to write a static recursive method that returns the frequency of occurrence a particular digit d in an integer n. For example, if passed (1342457,4) it should return 2, whereas when passed (1342457,6) it should return 0. I won't put my code in as it is arbitrary, I just need help with the logic in this one; I can't grasp what needs to be done. I should also note that no variables are allowed besides the two that the user inputs as the integer, and digit to be checked for (so it must be calculated completely recursively).

Member Avatar
Member Avatar
+0 forum 4

Here's a function that manually converts an integer to any base between 2 and 36, the parameter list is: [CODE]void toBase( int value, // Integer value to convert char *target, // Pointer to a large enough buffer int base, // Base (from 2 to 36) int fixedDigitCount // The minimum number of digits it must contain );[/CODE] This gives me the following output:[QUOTE]Binary with no fixed number of digits (1 to 15): 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 Binary with 4 fixed digits (1 to 15): 0001 0010 0011 0100 0101 …

Member Avatar
Member Avatar
+0 forum 2

The End.