C# :: Change Some Input Value Inside Code

May 12, 2014

I need to convert some input values in c#

for example if input is 0.0 then it should take value as 63.

0.5 as 62
1.0 as 61
1.5 as 60
2.0 as 59
2.5 as 58
3.0 as 57
:
:
:
:
28.5 as 3
29.0 as 2
29.5 as 1
30.0 as 0

now maybe I can define it in enum and use it but before doing that i wanna try if i can put an equation instead of defining these values into memory.

View 2 Replies


ADVERTISEMENT

C++ :: Coin / Money Change Code Doesn't Give Exact Change

Feb 20, 2013

My coin/money change code works when there can be an exact change each time, i.e. when the 1 cent option is available. However, when the change options are only $10, $5, $1, 25 cents and 10 cents, it does not give me what I want for instance, I wanted to get change for $237.80, I was expecting to get:

23 10's, one 5, two 1's and 8 dimes. However, the code below is giving me 23 10's, one 5, two 1's and 3 quarters (there is no option left for the 5 remaining cents).how to fix it?

Code:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void change(double cents, int a[]);
int main() {
double Dollars;
double cents;

[code]...

View 14 Replies View Related

C++ :: Logical Error - Change Value Inside Void Statement

Jul 16, 2013

I've encountered a slight logical error in my code

/*
Lab06_pensionplans.cpp
Purpose :
- Create a simple financial application to calculate retirement plans
*/
#include <iostream>
#include <cstdlib>
using namespace std;
void displayMenu() {
system("cls");

[Code] ....

Look at case 2, which the user supposed to key in a new input, the problem is the value will never got into main function, I don't know what should I modify with the function.

Figured out I need to change the

void changeData(int startingAge, int numOfYears,
double lumpSumAmount, double yearlyAmount, double interestRate )

into

void changeData(int &startingAge, int &numOfYears,
double &lumpSumAmount, double &yearlyAmount, double &interestRate )

View 2 Replies View Related

C++ :: Any Way To Change Font Using Code

Dec 20, 2014

Is there a way to change the Font size using code?

View 5 Replies View Related

C++ :: How To Change Input File Name

Mar 23, 2013

For particular assignment, I am asked to evaluate data from an inputfile, let it be named "infile.dat". Next, it is required to output to this same file, but with the name of this file altered to reflect the changes of data. For example, if I want to change the original file name to "changed_infile.dat.altered" by adding the "changed_" prefix and ".altered" suffix, how could this be done?

From my understanding, there are no functions in <fstream> that could change the file name. However, there is a rename function in <stdio>, but it's not exactly what I am looking for because I want to append a prefix and suffix to this existing inputfile name. Although I could apply a brute force method by simply doing rename("infile.dat", "changed_infile.dat.altered"), I want to have my program to work with various input files of different names.

View 1 Replies View Related

C++ :: How To Change Password Input To Asterisk

Mar 6, 2015

Code:
#include <iostream>
#include <string>
using namespace std;

int main()

[Code] ....

View 6 Replies View Related

C++ :: Struct Coinbox - Make Change For Input

Mar 14, 2013

I need writing the function that makes change for an input number. Input a bunch of quarters, dimes, nickels, pennies, then in MAKE_CHANGE the amount per say (184) is input. So for 184cents, runs through quarters first using the quarters we have in the coinbox, and then goes to the next currency for the remaining 9cents

(184/25=7 184%25=9).

#include <cstdlib>
#include <iostream>
using namespace std;
struct coinbox {
int quarters;
int dimes;

[Code] .....

View 1 Replies View Related

C/C++ :: Change Data Based On Users Input?

Feb 7, 2014

Player is given choice of x number of Races This choice changes the player's base stats. Then player is given a choice of x number of Classes (archer, warrior, etc.) This choice determines how the player's stats will change upon leveling up.

#include <cmath>
#include <iostream>
#include <ctime>

[Code]....

View 7 Replies View Related

C++ :: How To Change User Input To Display In Italic Font Style

May 29, 2014

How do I change User Input to display in Italic font style?

Let's say user inputs a word, then display that word in italic font.

View 3 Replies View Related

C++ ::  code Fails Due To Large Input

Jan 25, 2015

So the question is this [URL] .....

My code is this:

#include <iostream>
#include<cmath>
using namespace std;
int main(int argc, char *argv[]) {
long double div;
//div=((1e+9)+7);

[Code] .....

The problem is when the hackerrank inputs the following:

10
5351871996120528
2248813659738258
2494359640703601
6044763399160734
3271269997212342
4276346434761561
2372239019637533
5624204919070546
9493965694520825
8629828692375133

My code gives the wrong output.

The output is supposed to be

578351320
404664464
20752136
999516029
743537718
323730244
174995256
593331567
136582381
305527433

So what changes should I make to get my code give the correct output.

View 9 Replies View Related

C++ :: How To Get Code To Read Multiple Input Values

Feb 10, 2013

So I have to write a code for my C++ class, and I am having a problem trying to figure out how to get my code to read multiple int values. This is what my code should look like

Enter two times in military format (e.g., 1730 1520): 1730 1520
[1520<1730]
Enter two times in military format (e.g., 1730 1520): 1520 1730
[1520<1730]
Enter two times in military format (e.g., 1730 1520): 1730 1730
[1730==1730]
Enter two times in military format (e.g., 1730 1520): 1760 1520
1760: [INVALID TIME 1]
Enter two times in military format (e.g., 1730 1520): twelve 2
[INVALID NUMERIC INPUT]

View 1 Replies View Related

C++ :: Microsoft Code For Keyboard Input Interpretation?

Nov 22, 2013

at the moment my program is extracting keyboard data through accessing the virtual key states. However, it is not performing as I intended because the data I receive from the console does not concur with the actions the user performed.

E.G. When I type, it comes out like this.

what I get with my program: WWhhhheeen III typeeee, iiit ccoommes oout lllikkke thhhhiiis

TLDR: so basically Id like to know how other programs know how to interpret keyboard input, so that when I type I dont get multiple inputs of the same key press

View 2 Replies View Related

C/C++ :: Get Code To Sum A String Of Numbers Input From A File

Nov 5, 2014

This program gets input from a file and output to the screen and to a file. The difficulty I am having is summing the number I retrieve from the file for the individual numbers of sightings.

#include <fstream> // enables us to read and write files
#include <iostream> // for cin and cout
#include <cstdlib>
#include <string> // enables us to hold strings of characters
#include <cctype>
using namespace std;

[code].....

View 14 Replies View Related

C++ :: Give Appropriate Color Code For Resistor After User Input

Sep 18, 2013

I am in the process of writing a program that will give the appropriate color code for a resistor after the user enters an integer value for the resistance needed and selects the tolerance form a list. My question is this: Is there a way to allow the user to enter a value such as 75000 and C++ use each digit separately, as if they entered 7 [enter], 5[enter], 0 [eneter]... and so on? But, then use the entire value as an integer too? Also, it should read a value such as: 45835, as 45000, or 1843 as 1800.

View 1 Replies View Related

C# :: Writing Pseudo Code - Program That Converts Or Reverses Input String

Feb 20, 2014

I have made a program that converts or reverses an input string. Here is my code working fine

static void Main(string[] args){
string input = Console.ReadLine();
string[] words = input.Split(' ')
for (int i = words.Length; i > 0; i--)
Console.Write(words[i - 1] + " ");
Console.WriteLine();
Console.ReadLine();
}

How can I write this program in pseudo code?

View 2 Replies View Related

C :: Print Out - Array Code And Pseudo Code?

Apr 15, 2013

I have assignment which requires me to print out and array code and a pseudo code. I dont no what a pseudo code is,.

View 2 Replies View Related

C++ :: Reducing Code Duplication From Common Code Calling Common Class

Apr 13, 2014

I have a class 'A' which is almost perfect for my needs. Class 'B' uses class 'A' I've now designed Class 'C' and Class 'D' and noticed that there is a good chunk of code in class 'B', 'C' and 'D' for using Class 'A' is duplicated. I've separated out this code in specific, standalone functions in each of the classes. Now I'm wondering where this code should go. At the moment, the functions are duplicated in the three calling classes (B, C and D). Placing the functions into class 'A' would break the single responsibility principle. Inheritance to add functionality would likely break both SRP and LSP. The one that seems that it may work is composition.

However, Is designing a complete class just for a few functions over kill?

Would it be valid for classes 'B', 'C' and 'D' to access both the new class 'E' (which would depend on A) and the old class 'A' (which would have to be the same instance as the instance in the new class 'E'), or should the new class 'E' provide sufficient functionality so that Classes B, C and D don't need to access Class A directly? It would seem that its then an incomplete interface of the original object with additional functionality (ie, incompatible) Or should I do it a completely different way?

View 4 Replies View Related

C++ :: Store Map Value Inside A Map?

Oct 13, 2014

How do you store a map value inside a map?

Here's my code:

map<map<string, string>, int> Name;

View 6 Replies View Related

C++ :: Map Inside A Map Sorting

Feb 21, 2015

I have a map which contains a multiset and another map

std::map<std::multiset<int>, std::map<int, int> >

And I need to sort the whole map according to the mapped value of the inside map, then output the data from the keys i.e. from the multiset and the first value of the inside map. I have tried to create a vector of pairs

std::vector<pair<std::map<:std::multiset<int>, std::map<int, int> >, int> >

and populate the first element with the map and where the second integer of the pair will be the mapped value to sort. I have tried iterating over the map to populate the vector but I'm not sure how to do so.

View 9 Replies View Related

C :: Using Or Inside Case Arguments

Nov 6, 2013

I would like to choose same case for multiple switch conditions.

For example:
Code: switch(choice) //''if choice ==0 or choice ==1, chose same case''
{
case (0 || 1):
{
//execute steps
}
break;
default:
{
//execute steps
}
break;
}

The '||' inside case does not have the desired effect (although it compiles fine). How can I do it without using if-else statements.

View 1 Replies View Related

C++ :: Having A Function Inside For Each Statement

Dec 4, 2014

I keep on getting error message while trying to pass a function inside a for_each loop.. I have a vector and i used for_each loop to go through the rows in that vector, Now I need a function to do something

Example this is what I am trying to achieve

for_each (label.begin(), label.end(), addToTemporaryVector());
void DataPartitioning::addToTemporaryVector(){
cout<<"sucess";
}

But I get an error message saying: error: invalid use of void expression

View 2 Replies View Related

C# :: Getting Coordinates Inside Image

Feb 25, 2014

I am working on a small game and I have the following problem. I need to get the colour of a particular position in an image. Say I'm given coordinates (5,5) I need the colour of the part in the image. I think I can do the colour picking myself, but I don't know how to point at coordinates inside the image.

View 3 Replies View Related

C/C++ :: Can Make Squares Appear Inside The Other

Mar 21, 2015

[URL] ....

Can I make these squares appear around the other instead of having them appear under the others. Also if it can be done how can I make it so there is a space between the squares

int main() {
char a;
int size = 0;
cout << "Enter a character: " << endl;
cin >> a;
while (size < 1 || size > 10)

[Code] ....

View 1 Replies View Related

C/C++ :: How To Tell If Point Is Inside Triangle Or Outside

May 13, 2014

So, I have created a class called "point" and i have 4 "point" objects. They only have 2 variables, x and y (their position). The first 3 points form a triangle and now I need to tell if the forth one is inside or outside. I have found some solutions but they involve heavy math (they are based on the sum of the angles or something like that). I want to know if there is any way to solve this only by using the distance between points. I have created a function which takes 2 "point" objects and returns a float value which is their distance.

Here is some code:

#include <iostream>
#include <cstdlib>
#include <math.h>
using namespace std;

[Code]....

View 5 Replies View Related

C/C++ :: Possible To Ask Yes / No Question Inside Of While Loop?

Apr 2, 2014

I'm trying to create a simple calc program that does all the elementary calculations. How to get it to add and multiply continuously without crashing. but now i need to figure out how to ask the user if they want to continue or not. I'm having trouble here because in the while statement i have a scanf which asks for the operator symbol. and then asks for number in the second scanf..

So basically a user would have to enter 'R' twice for the message to pop up! Also i'm not sure how i would quite the program if they put in a 'N' for no. would return 0; work? What if they press 'Y' for yes, what would the return have to be then?

Here's a snippet of the code
int main () {
double result;
double new_number;
char symbol;
result = 0;
while(1==scanf(" %c", &symbol) && symbol == 'R' && symbol =='r')

[Code] .....

View 9 Replies View Related

C/C++ :: Using A Point Inside Vector?

May 12, 2014

I am trying to write a basic editor program and one of the parts asks me to "process dot commands that move point in whole line increments"

Earlier it says that a point is interpreted as specifying the location between characters rather than the characters themselves. and i need to use this to implements the following:

< moves point to the beginning of the document. > moves point to the end of the document. p moves point to the beginning of the previous line. n moves point to the beginning of the next line. k deletes the current line and leaves point at the beginning of the following line.

(there was a previous part before this so i already have some code that works) and in this part I'm trying to do a switch case

ie

for
< , >, p , n and k

I guess my question is how do i make this "point" need. Ive been using vectors, so the point needs to be somewhere inside the vector. I don't think ill be able to do what i need to do with out the point.

View 14 Replies View Related







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