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
ADVERTISEMENT
Nov 15, 2013
Using functional decomposition, write a C++ program that will prompt user for the all the color bands of a resistor and then calculate the value of the resistor.
The first 3 bands are digits, the 4th is power of 10X and 5th is tolerance.
Here is what the picture look similar to : [URL] ....
if 1st is green (value 5)
2nd is blue (value 6)
3rd is black (value 0)
4th is orange (value 3)
5th is silver (10%)
resistor is 560 x 10^3 with 10% tolerance. or 560 Kilo-ohm with 10% tolerance
a sample program out put:
char BAND_COLOR_CODE[10][8] = {“black”,”brown”,”red”,”orange”,
“yellow”,”green”,”blue”,”violet”,
“grey”,”white”};
[Code] ....
View 1 Replies
View Related
Jan 27, 2013
i am using c++v30.5 version i want red color text in in my output screen . i viewed various site but the result is 0 ,wat to do?
View 2 Replies
View Related
Apr 11, 2013
how to give a database connection to a c++ code i am using turbo c++ as an editor and if i have oracle 11g client, odbc as a driver , what else i require and how to link these things in a code.
View 1 Replies
View Related
Dec 30, 2014
i have only recently got into programming. i have this homework assignment that is frying my brains, the program needs to take a number from the user and give the 'reduced' sum. for example: if the user enters 888 then the sum should be: 6. it takes the number and adds its digits im just looking for a direction to where my problem is
#include "iostream.h"
int reduction (int number) {
return number/10+number%10;
}
int main() {
int number,loopcount;
cout<< "please enter a number"<<endl;
cin>>number;
[Code]...
View 2 Replies
View Related
Nov 2, 2013
Code:
#include<stdio.h>
void main
{
int i;
int marks[10];
}
[code]....
how to give error and ask user to re enter if user enter other then a number?
View 6 Replies
View Related
Jan 11, 2014
I have created an error message if the user inputs the wrong selection number
if (choices < 1 || choices > 5)
{
cout << "
Please Enter a number between 1-5
";
}
How would i create a error message if the user inputs letters/words instead of a number.
View 5 Replies
View Related
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
Sep 7, 2014
Trying to define some global colors so I can use the one instance though-out my application. Here is my color code:
<Color x:Key="GlobalTextColor">#E0E0E0</Color>
But this color doesn't display in the list when I start to type {StaticResource ...}
This is the code where I'm trying to reference the color, see Stroke="{StaticResource GlobalTextColor}". GlobalTextColor doesn't actually come up in the list so won't work.
<Style x:Key="InputButton" TargetType="Button">
<Setter Property="Background" Value="#FF141414" />
<Setter Property="HorizontalAlignment" Value="Left" />
[Code].....
View 2 Replies
View Related
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
Oct 27, 2013
I came up with this code to try to add each number from a zip code inputted by the user but I think I'm adding up the ascii values not the real values the user is inputting. How I can go from ascii to the real digit. This is my code so far
#include <iostream>
#include <iomanip>
#include <string>
#include <conio.h>
using namespace std;
int main() {
int total = 0;
char ch[5];
cout << "Please input your 5 digit zip code: ";
[Code] ....
View 4 Replies
View Related
Oct 27, 2013
I'm trying to write a code that takes two arrays from the user (presumably in ascending order) and then passes the sizes of both arrays and a pointer to each to a separate "int* mergeArrays" function that will merge sort the two. I've written a lot of the code, but I can't get it to compile. I get errors: lab6.c: In function "main":
lab6.c:31:14: error: expected expression before "int"
mergeArrays(int* firstArray, int size1, int* secondArray, int size2);
^
lab6.c:31:14: error: too few arguments to function "mergeArrays"
[Code] ....
View 2 Replies
View Related
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
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
View Related
Apr 24, 2012
We had to write a "selling program for computers, laptops and tablets", which I did but for the extra credit, we have to have those three points in the application and I have tried but how to do the "extra credit" part, which I really need.
1.) A loop to prompt the user if they would like to place another order
2.) At least one user-defined function
3.) An enumerated data type, array or struct (structure)
I did one of these three, it's a "DO WHILE" loop asking users if they want to make another order, it's right at the beginning of the code.
Code:
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
double desktop();//function prototype
double laptop();
double tablet();
[Code] ....
View 2 Replies
View Related
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
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
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
Apr 9, 2014
I am trying to write code to find all the prime numbers before a user entered number. I started with a working program and when I tried to create a function, it got all messed up.
Code:
#include <stdio.h>
int is_prime( int num );
int get_positive_integer(void);
int main( ) {
int upper; /* upper limit to check */
int num; /* current number to check */
int isprime;
/* used to flag if number is prime or not */
[Code]...
It says the error is on line 23
View 6 Replies
View Related
Sep 14, 2013
I'm expected to write a c program for this question :
Using these header files
#include <stdio.h>
#include <conio.h>
Question : Write a program that will prompt the user to enter an integer value and a character code to indicate whether they want to do a Kilogram to Pounds conversion (A) or a Pounds to Kilogram (B) conversion. Note that 1 kg = 2.2 pounds. The program should then do the necessary conversion indicated by the code and display the newly converted value to the screen.
View 1 Replies
View Related
Oct 26, 2014
Design an algorithm using flowchart or pseudo-code to prompt the user for a series of positive integer values. Calculate the average of these values and display the average at the end of the program. Assume that the user types the sentinel value -1 to indicate end of data entry.
Sample input-output:
Enter a positive integer (-1 to end) : 5
Enter a positive integer (-1 to end) : 7
Enter a positive integer (-1 to end) : 6
Enter a positive integer (-1 to end) : -1
The average value is: 6
I searched online and found out this solution however it is only for three numbers.Is there any way of modifying this to include the sum of x numbers / number of x(integers) to find the average?
View 5 Replies
View Related
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
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
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
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
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