Visual C++ :: Allowing User To Input Decimal?

Oct 21, 2013

This code is near complete, the only task that is left is allowing the user to input a decimal and then two integers, or automatically using .00 decimal.

The automatic part: /*This is not correct.

printf(".%.2d
", number);
*/

But that does no good for me. Question: Do I have to create a some sort of while loop again, to allow the user to input a decimal followed by integer?

Code:
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
int j , i = 0, k = 0;
int number;

[code]....

View 1 Replies


ADVERTISEMENT

C++ :: Allowing For User Input Of Equation To Be Evaluated

May 14, 2014

I've written a program that finds the maximum of a function. I now want to change it a little so that instead of evaluating the function y=x^2-7x-18, the program will ask the user to input an equation and then evaluate that equation. I'm really not sure of how to do so.

#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
int main() {
int a, b, delta, x, y;
double max= -1.8 * pow(10, 308);

[Code] .....

View 3 Replies View Related

Visual C++ :: Taking Decimal Input From The User

Feb 21, 2015

I want the input for the price in decimal format(15.00). If the input is in integer format then I want to convert it to decimal format.

The maximum price for a sale is 999.99 and minimum is 0.00.

I have tried so far:

Code:
#include<iostream>
using std::cout;
using std::cin;
void main(){
float eventPrice;

[Code] .....

A valid input will be:

1.8,
0.8,
0.00,
0,
9,
99

View 2 Replies View Related

Visual C++ :: Converting Decimal Number Given By User To Binary?

Dec 19, 2014

Write a C++ program that adds three binary numbers of 8-bit each. Every number is stored into an array of 8 elements.

Example:

Array A
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0
+
Array B
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0
+
Array C
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0

Store the result into an array D of 8 elements. Your program should show the decimal numbers for every binary number. Print screen of 6 answers. This means you should try your program six times with different numbers in every run and show the printed screen result.

View 5 Replies View Related

Visual C++ :: URLDownloadToFile Not Allowing The Program To Return Value

Jun 2, 2013

I've been writing some code and this is part of it:

Code:
...
URLDownloadToFile(NULL, _T("http://something/something.txt"), path, 0, NULL);
return 0;
}

The file gets downloaded successfully but the downloader wont exit (return value 0). So it remains active.

I am sure the problem is URLDownloadToFile()

I am using Visual Studio 2010 Express.

View 6 Replies View Related

Visual C++ :: Program That Take Input From A User And Calculate It In A Do While Loop

May 15, 2013

I'm trying to create a program that will take input from a user and calculate it in a do-while loop. The program does the calculation but the answer is wrong. The loop also doesn't work. The purpose of the program is to see how much an item will cost after a discount is taken off and tax is added.

#include <iostream>
#include <cmath>
using namespace std;
double original_cost;
double discount;
double tax;
double total;
char answer;

[Code]...

View 2 Replies View Related

Visual C++ :: Find The Location Of Certain Digits From User Input

Sep 24, 2013

I have been trying to finish this code (function) for a while now, but am stuck on the last part. In this code, I prompt the user to select a number of integers and any number of digits and then find the smallest and largest value within these digits. On the next part, I am supposed to determine which of the given digits the smallest and largest are located such that the output should be:

Digit _ can be found in integer number(s): _, _

Here is what I have tried:

Code:
int digitSizeLoca() {
int userNumInteger;
int* iPtr;
int* iPtr2;
int* iPtr3;
int value;

[Code] ....

Seems to do the job, but it always outputs 1, 2...

View 4 Replies View Related

Visual C++ :: Using Loop To Take User Input And Keep Running Sum Until 0 Entered

Feb 28, 2013

I am stuck on an exercise where i am supposed to use a loop to take user input and keep a running sum until the user enters a 0. the code i have so far is:

#include <iostream>
int main() {
using namespace std;
int num;
int total = 0;
int x;

[Code] ....

The full text of the error message is: error c2678:binary'>>':no operator found which takes a left-hand operand of type 'std::istream' . and one more thing i was wondering, is there a difference between c++ and visual c++?

View 4 Replies View Related

Visual C++ :: Write A Program Where The User Will Input Integer Numbers?

Oct 21, 2014

I have to write a program where the user will input integer numbers. How many numbers they enter is unknown, therefor you should use a repetition structure for the input. When the user is done, they will enter -1 to exit.

Create a dynamic array if the size=2( the initial size must be 2) Repeat until user enters -1.

I have to do this without using vectors.

This is what i have, I cannot figure out what to put in main. I was thinking of a do-while?

Code:
#include <iostream>
using namespace std;
void resize(int *[], int);
int main() {
int *listDyn;
int size=2;

[code].....

View 5 Replies View Related

Visual C++ :: User Input In Two Arrays - Comparison Always Show Zero Correct Answers

Nov 3, 2012

The following program takes user input into two arrays and should then determine how many items are different by comparing them with a loop. The comparison always show zero correct answers.

#include <iostream>
using namespace std;
const int QUESTION = 20;
//class for testing grades
class TestGrader {

[Code] ....

View 4 Replies View Related

Visual C++ :: Search Function - Ask User To Input Name And Brings Out Line From TXT File Containing Information

Dec 8, 2013

How to get this thing to work. All i need to do is ask user to input a name and then it brings out the line from the .txt file containing the information.

For example in my case I'm doing a member search function I'm required to ask user to input the name of the customer and then print out all the details (which consumes 1 text line in the .txt file)

Here is the code, This is the write to text file method (100% working)

Code:
cout << "Customer Name: ";
cin >> name;
// ...
ofstream myfile("customer.txt", ios::app);

[Code] .....

View 3 Replies View Related

C :: User Defined Number Of Decimal Places?

Sep 2, 2013

I need the user to be able to input the number of decimal places they wish to have displayed in the output. Everything works fine as is, I just don't know how to allow for the user to input the number of decimal places they want the output to have.

Code:

#include<stdio.h>
#include<math.h>
#define PI 3.141592654
int main(void) {
//Local Declarations
int x; //desired number of decimal places
float radius; //radius of circle
float circumference; //circumference of circle

[Code] .....

View 2 Replies View Related

C++ :: User To Enter Decimal Value Then Display Its Corresponding Binary Numbers

Sep 13, 2013

Create a program that will ask the user to enter a decimal value (1-999999) then display its corresponding binary numbers. Repeat this process until the value entered is equal to 0. Use the following Function Prototype:

void BinCodes(int value);
Sample Input/Output:
Enter a Decimal: 35
Binary: 100011
Enter a Decimal: 184
Binary: 10111000
Enter a Decimal: 0

View 4 Replies View Related

C :: Simple Decimal Input To Binary Output

Jun 22, 2013

I am learning c because I want to get back into programming microcontrollers, which I previously did in assembly. I wanted to make something fairly tight in terms of program memory and RAM to show me an output in binary form. When you are troubleshooting a file register or serial interface when you can see the actual bit values (on a small LCD for a micro-controller) and compare it to a datasheet.

Code:
#include <stdio.h>
#include <math.h>
int main() {
int i;
int decimaltoconvert;
int convertingarray[7];
int convertingarray2[7];

[Code] .....

Also, how might I go about putting that into a function that I could call?

View 6 Replies View Related

C/C++ :: Getline Not Allowing To Read A Sentence

Apr 15, 2014

I wrote this program:

#include <iostream>
#include <ctime>
#include <ctype.h>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

[Code] ....

LETTER OR '.' ? s
LETTER OR '.' ? f
LETTER OR '.' ? b
LETTER OR '.' ? e
LETTER OR '.' ? a
LETTER OR '.' ? g
LETTER OR '.' ? .
VECTOR : [ SFBEAG ]

SENTENCE ?

But after this i can't write anything. Do you know why? I've never had problems with getline... when i used cin >> it read but only one word. Now it doesn't even let read...

View 1 Replies View Related

C++ :: Accept Signed Decimal Integer As Input And Output In Binary

Jan 29, 2015

Write a C++ application program to accept a signed decimal integer as input and output the equivalent 2s complement version in 16-bit binary. Include a space between every four bits in the output string. The input will only be processed by the application if it falls in the valid range that can be represented in 2s complement format with 16 bits. The range of a decimal number from - to + is -32768 to 32767.

View 3 Replies View Related

C++ :: User Array Size And Sorting User Input

Nov 1, 2014

I am making program that allows the user to determine how big the array size will be and then asks the user to make up numbers to fill the array. Every time run the program on Dev C++ it says "program has stopped working"

Heres My Code:

//Assignment 19 Program 2
#include <iostream>
using namespace std;
int main()

[Code].....

View 3 Replies View Related

Visual C++ :: Binary To Decimal Converter?

Oct 5, 2014

I'm trying to figure out why the binary to decimal part is not working correctly when the binary value finishes with a 1. In those cases, the decimal value shown in one unit smaller than it should be.

Code:

#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
void Binary_to_Decimal(), Decimal_to_Binary(); //prototype for the 2 functions that contain the converters
int main() //the menu {
int a_Choice;
cout << "Enter 1 - for binary to decimal" << endl;
cout << "Enter 2 - for decimal to binary" << endl;

[code]....

View 2 Replies View Related

Visual C++ :: Roman Numeral Converter To Decimal Using Array Of Strings

Jun 27, 2013

This program compiles, but has a bunch of logical errors. I know my problem is somewhere in the while loop that I have, but I can't figure out where. Here are some of the issues I am experiencing:

1. At the beginning of the program it asks you to enter a number, and when you do it does nothing while proceeding to the while loop where I have it asking the same question

Code:
"Please enter a number between 1 and 20 (Enter 0 to stop)
";
cin >> num;
cout << endl;

I want to be able to eliminate that first statement but if I only run this in the loop without the above statement the program will display nothing on the screen and proceeds to stop.

2. This code runs fine, except that if you make a mistake, it will prompt you to enter a valid number, however; it ignores your first response if the number you enter is valid and asks you to enter a valid number anyway. Once you enter it a second time, it will accept it and the program will continue on.

Code:
while(num != SENTINEL) {
cout << "Please enter a number between 1 and 20 (Enter 0 to stop) ";
cin >> num;
cout << endl;

Also if you type in 0 on your first response, it will prompt you that it is not a valid number and ask you to try again, instead of stopping the program like it is supposed to do. On your second response the program will accept your 0 and stop the program correctly.

//Write a program that displays the roman numeral equivalent of any decimal number between 1 and 20 that the user enters. The roman numerals should be stored in an array of strings and the decimal number that the user enters should be used to locate the array element holding the roman numeral equivalent. The program should have a loop that allows the user to continue entering numbers until an end sentinel of 0 is entered.

Input validation: Do not accept scores less than 0 or greater than 20

#include <iostream>
#include <string>
using namespace std;
int main() {
// Declare constants and variables
const int romanNum = 21; // Size of the elements in the array

[Code] ....

View 14 Replies View Related

C++ :: Input Decimal Number And Output To Be Number Scientific Notation

Apr 26, 2013

I need to write a code in c++ , to input decimal number and the output to be number in Scientific notation with 32 bits .

View 1 Replies View Related

C++ :: Second User Name Input Is Being Skipped

Jan 1, 2014

In this simple end-of-chapter problem, the ages of two people are to be compared and determine who's older. The problem I'm experiencing is that the second user name input is being skipped and going straight to the second users age.

So while running the program it looks something like:

What is user ones name?
<input name>
How old are they?
<input age>
What is user twos name?
How old are they?
<input age>
<if statement result>

Here's my code:

Code: #include <iostream>
#include <string>
using namespace std;
int user_one_age;
int user_two_age;
string user_one_name;
string user_two_name;

[code].....

View 9 Replies View Related

C# :: TexBox User Input To Hex Value

Sep 2, 2012

So I've got this form that a user puts in a numeric value into a text box. This value then has to be placed into a byte string of data so that it can be transmitted over as a packet. Bellow is what I have so far:

Code:
Byte[] OUTBuffer = new byte[65];//Allocate output memory buffer
Byte[] INBuffer = new byte[65]; //Allocate input memory buffer

if (setmSpeed == true)
{
OUTBuffer[0] = 0; //Not used, must be set to 0
OUTBuffer[1] = 0x85; //Command mode

[Code] ....

I've put in red the area where I'm having issues. I've tried different methods and have not been able to get this working yet. It only works if I speciffy the value manually as with OUTBuffer[1] = 0x85;, but I want byte 2 of OUTBuffer[] to be set with what I put in the text box.

View 4 Replies View Related

C :: User Input To File

Mar 18, 2013

I'm creating a program that should create a structure of a list of people entered by the user; the only problem I'm having is with the %c. When I have it, the loop only occurs once; if I put a %s, the loop occurs up to 25 times, but it doesn't write to the text file. Here is the code:

Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
[code]....

View 2 Replies View Related

C :: User Input With Forks

Apr 7, 2013

So im working with forks and creating 2 fork processes. One child and parent. What im trying to get the child to ask me for a value. Then the parent would start to figure out the value and keep trying. Once it figures it out its tells them you got it and simply stops the program. I cant seem to get the program to keep guessing and stop when the number is found which sends a sigint. Here's what i have so far.

Code:
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <stdbool.h>

int main() {
int j, i,pid;

[Code] .....

View 2 Replies View Related

C++ :: Alter User Input

Feb 6, 2013

I have this code here that counts the number of alphabetic letters the user's input,the number of characters total, the number of words and the number of "the" that was used. However now I need to alter the user's input to have two spaces after the end of each period, no spaces between a word or comma and each sentence has to have a capitalized letter and display them at the end. And I'm stuck on the altering part. I briefly started the 2 spaces after each period but it won't display anything.

#include <cstring>
#include <iostream>
using namespace std;
int main ()

[code]....

View 7 Replies View Related

C++ :: Trying To Get User Input Into Array

Apr 25, 2014

I have written a program and i had to pass an array into a function and now i have a variable for the subscript of the array and i was the user to input data, specificlly a string, more specifically first and last name without having to create two arrays, i have to do this with other things in the program as well, here is part of the program:

int addFunc(const int totNum, string city[],string state[],string street[],string name[],
int addNum[],int zip[],int telNum[],double bal[],int dateLp[], int addCount, int accNum, int usNum)//function will add a new account {
int countAf = 1;
if (usNum < 20)

[Code] ....

it should be able to take firstname space lastname

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved