C++ :: Temperature Conversion Is Coming Up Wrong When Enter In Input
Feb 1, 2015
How would you be able to show both outputs celsius and Fahrenheit and my temperature conversion is coming up wrong when i enter in the input. here is my code...
#include<iostream>
using namespace std;
int main(){
double celsius;
double fahrenheit;
I am trying to convert uint32_t or unit16_t to chars in little endian. When I was reading the char s from binary file I used memcpy so I did not need to convert them, but now I try this:
In the last function I try either to cast to uint_32_t or unsigned char but in both case I got wrong values. The original binary string read from left: 0x36000003 (it is number corresponding to 48Mbytes).
And the result when casting to unsigned char is T000000 and T(>00 for uint_32. So what's wrong? I need to get some string with will be corresponding to 0x36000003. does this kind of convertion take a lot of compute performance when I one would use it offten (like when one would do convesions for bitmaps).
I have to write a program for a restaurant and their food has to be cooked on a hot sheet of metal and too cook their burgers properly I must keep a maintain temp of 400 F, for the grill and to measure the temperature using a probe at 12 points, there are 3 elements with 3 points on them
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.
I'm writing the program below to take an integer input for temperature and display a cheesy message for different ranges for each day of the week.
I tried using two if statements, the first to determine if the input is valid, and the else display that it was invalid and to try again.
The second set of if (if else) statements would evaluate a number input and display the cheesy message based on the value, or if it was out of range, to make you re input that days temperature.
I understand that the else statement is linked to the closest if statement, unless brackets are added to prevent this. I thought my brackets were correct, but I keep getting [Error]'else' without previous if'. The red lines are the if and else statement I'd like to be linked, and tried to do so by enclosing the 2nd if statement in brackets.
The assignment doesn't require the error checking, but if I don't use some form of it I believe it will just loop. Again I have to use the last 4 lines due to instructors rules, and have to use scanf and not strings or arrays.
This program will ask the user what the temperature will be for each day of the week. The integer input from the keyboard will be tested in a series of IF tests and a message will be printed depending on the temperature.
i'm making a for loop for a mini game which required the user to enter the input number.Let say if the user accidently entered a character instead of integer the whole program will go haywire so is there anyway to check for the error and prompt the user to input the data again?Here is the simple program...
I have this function that is supposed to take a float as a parameter and then call the getLine() method to accept the users input. The function basically just checks to see if what the user input was of the same data type, if it is it returns the input value, if not then it keeps looping through taking new input until its correct. The problem is no matter what number you put in the output always returns as 140734799803512.
float InputValidation(){ float num; string strInput; while (true){ getline(cin, strInput);
I have a question about my program.. I would like to make a program that if you put "ABC" on INT, the program will restart again... below are my coding...but it not works..if i put ABC on INT, the "Invalid Mark.. please re-insert mark :" will repeat, repeat and repeat infinitely...
So I'm writing a program that will read a text file and it will do certain "functions" the text file will be like a game, and the program will be able to run many different games. The problem i'm having is in one of the "functions" i believe it's the one meant to get a correct choice from a file and a user input and put them into strings, it gets the wrong input. I know this because i tested both strings the "function" writes too. it gets the correct file answer but the user input is always "c" for some reason.
#include "stdafx.h" #include <iostream> #include <iomanip> #include <fstream> #include <string> #include <stdlib.h> using namespace std; int progfiles() {
[Code] ....
This is the code, most likely the section that is surrounded with "///" contains the problematic "functions." This is the command Line output...investigate why they're dieing or continue on your journey?(i-investigate/c-continue) got input and answer
i c i Press any key to continue . . .
The got input and answer are tests to make sure it got both, the first 'i' is my input, the 'c' is what it says my input is, and the 'i' is the correct answer from the file. this is the part of the file that the program reads to get that output
"1 Do you want to go investigate why they're dieing or continue on your journey?(i-investigate/c-continue) 2 8 i 7 3 4 You continue on picking up speed to get to the egg first.. and.. Oh No, You accidentally bumped into the walls! 2 12 5 1 You go over, and as you realize the walls are acidic and that's why the other sperm are dieing.. 2 6"
I wrote a program that reads user input string using fgets() function. After this, program will ask if the user wants to save the string to file or does the user want to change the string or quit without saving. If user wants to change the string this must be made possible by asking for the string again. After this, menu will be printed again printing the choices available.
I had to flush stdin before getting changing input! However, problem is "Why do I have to hit return key 2 times, when I choose 2 and input string again." (I use code block 13.12 with windows 8.1 laptop) */
Code: #include <stdio.h> #include <string.h> #define MAX 50
Basically I'm having trouble reading more than one character.I want the user to input character traits(ie, w, a), if two traits are entered they get the job.
But I cannot get my program to read more than one character input.
This is what I have so far...
#include <iostream> using namespace std; int main(){ char input; int count = 0;
When the program is processing/sleeping, those char input at that time would not goes into the buffer until the next input request (such as calling istream::get). The program below shows this.
I wonder if there is a way to distinguish between the input comes from the time that does not request it (i.e., during processing or sleeping) and those comes after the time does request it (in the example, after "Input something: ").
I'm trying to validate my input. I require for the user to enter six doubles and if they don't then I want them to re-enter the information. Here is my code:
Code: while (1>0) { printf("Please enter arguments in the order: negative mass, positive mass, initial x-position, initial y-position, initial x-velocity, initial y-velocity: ");
if ( scanf("%lf %lf %lf %lf %lf %lf",&MassMinus,&MassPlus,&Pos[0][0],&Pos[0][1],&Vel[0][0],&Vel[0][1]) != 6) { printf("Not all numbers were assigned!
[Code] .....
At the moment it just waits if you enter less than six numbers and if you enter any more than 6 it just ignores anything after the sixth number (so pretty much does nothing). Also if I entered 1 2 a b 3 4 instead of entering six numbers it would register that as 1 2 0 0 3 4 but I want it to make the user input the numbers again. I'm also aware that "while (1>0)" isn't good programming form but I'm not really sure what to use instead?
When the user gives no input, they have to press enter twice before "Done." is printed.
cout << "What do you want the name of your page to be? "; std::getline(cin, pageTitle); if (cin.get() == ' ') pageTitle = "Welcome to Website."; cout << "Done. ";
Is there a way to print "Done." after pressing enter once?
Code: #include<iostream.h> #include<conio.h> #include<string.h> void main() { clrscr(); int i=0,flag=1; cout<<"Enter the password.";
[Code] ....
When I input the password, the Backspace and the Enter keys are not working as they should. Also, I want to know if I can press enter only once to input the password, not twice.
how can i make a program which allows a user to enter an input for a time interval for example i ask a question and sets the input to be entered within 10 seconds...
It seems to be going null. I can't get a null value, I want it to accept input till the user hits enter with no text typed. I've tried checking to see if the input is NULL, "", and " " all to no avail.
Code: #include <stdio.h> #include <sys/shm.h> #include <sys/stat.h> #include <iostream> #include <fstream> #include <string.h> #include <cstring> using namespace std; int main() { string info = "";
I am working on a quadcoppter and am having trouble trying to parse the output that I am getting from the sensor. This is the code that I am trying to get to work but the Arduino compiler is saying that i can't convert and int to a string unfortunatley I am trying to get the string to convert to an int.
Code:
//string that will be processed is this //Ax=-209 Ay=5 Az=1116 | Gx=7 Gy=0 Gz=7 | -31 233 -433 Headings 100.20 void setup() {
I'm trying to write to a named pipe created by a service, as we all know the session 0 isolation implemented in vista and forward makes this task a bit complicated.
well at this point i managed to make almost all to work but my real problem comes when i try to write on the named pipe from my GUI application with no administrator rights
If i run the GUI application with admin rights it works 100% but, I don't need that application to require the user admin rights and for security reasons i rather to leave it without admin...
so i started my research and i found that there is a way to achieve this by calling CreateNamedPipe() with a low integrity security attributes...
well how to implement but i finally made it, the problem is that it gets worse than passing null security attributes, it works with admin rights with NULL security attributes, but when i pass the low integrity security attributes it gives "access denied" even when using admin rights, so i guess im passing the wrong security attributes but how to manually create the security descriptor string.
I want to make an application that will check CPU/RAM USAGE and CPU TEMPERATURE and if it meets some requirements it will restart your system or do something else..but my problem is:
1) How do i get that info? (i know that in VB.net there is an easy way) but in C/C++ or Java?
2) Is it possible though a C program to execute a command and parse that info to your program?
I am mainly interested for windows but i need also info for linux too..
#include <iostream> #include <iomanip> using namespace std; //function prototypes int getFahrenheit(); double calcCelsius(int tempF)
[Code] ....
for some reason it keeps giving me a Error C2144: syntax error: 'int' should be preceded by ';' on line 16 column 1 Error C2143: syntax error: missing ';' before 'return' on line 34 column 1 IntelliSence: expected a ';' on Line 34 Column 2
I have tried to fix both of these problems and no matter what I do I either get more errors or they wont go away...
The program should create two integer variables for the temperature in Celsius and Fahrenheit. Initialize the temperature to 100 degrees Celsius. In a loop, decrement the Celsius value and compute the corresponding temperature in Fahrenheit until the values are the same. But for some reason i either get no output or an out put of -43.
#include <iostream> using namespace std; int main() { int celsius; int fahrenheit;
Note: Windchill Temperature is only defined for temperatures at or below 50 degrees F and wind speeds above 3 mph. Bright sunshine may increase the wind chill temperature by 10 to 18 degrees F.
I am trying to write a program where i take temperature in Fahrenheit and convert it into centigrade. I keep getting this error "The program '[5980] lab3.exe: Native' has exited with code 0 (0x0)."
My Code is :
#include <iostream> using namespace std; int main() { double fahrenheit, centigrade; cout << "Enter the temperature in Fahrenheit: "; cin >> fahrenheit; centigrade = (5/9)(fahrenheit-32); cout << "The Temperature in Centigrade is " << centigrade << endl; return 0; }