I have this code in order to make a RPN calculator,but im trying to read from the console entering the expression in reverse polish notation,Also I think it will be better to use fgets() instead of scanf since the person can entere something like this 3 2 1 + x
I have my Reverse Polish calculator compiling and everything but for the assignment I need to handle a few exceptions that I can't seem to get. First off I'm trying to make the program exit if the user enters only "0" but since the input i'm using is string, I cant figure out how to code
"If the first node is 0 and the next node = NULL, return true"
Here is my code: #include<iomanip> #include<iostream> #include<stdlib.h> #include<stdio.h> #include<string> #include<sstream> using namespace std;
Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following function: a function to convert the time from 24-hour notation to 12-hour notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, function(s) to get the input, and function(s) to display the results. (For 12-hour time notation, your program must display AM or PM.)
It is showing error because may be I was not able to put that if statement inside any function. find out the error sand complete the program with corrected code.
I am having problems compiling this program. line 29 causes the error "left operand must be l-value".
// chap5proj.cpp : Defines the entry point for the console application. // # include <stdafx.h> # include <iostream> using namespace std; int main() { double mph, time, disPerHour, milesTrav;
I am getting this error when compiling my program with quincy:
Error: I value required as left operand of assignment
The program is meant to calculate how much parking costs based on the amount of hours in a park and what type of vehicle it is. the error is coming from my function definitions which i have just started to add in.
Code: float calcCarCost (char vehicletype, int time, float car) { if ((time > MINTIME) && (time <= 3)) calcCarCost =( CAR * time ); }
The error is on line 72 which is: calcCarCost =( Car * time);
I should probably point out CAR is already defined as a constant with a numerical value given and time is previously asked to be input in when the program runs.
The issue arises with case 3 where it tells produces an error when I attempt to compile and says "lvalue required for left operand of assignment error". How to fix this so that I can properly run the program.
I get Error this error. Did I miss something or is that some kind of bug?
Code: error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion)301
Code: 2IntelliSense: no operator "<<" matches these operands operand types are: std::ostream << const std::string307
while (getline(inStream, line)) { while (inStream >> Student.getId() >> Student.FNAME >> Student.MINIT >> Student.LNAME >> Student.GENDER >> Student.UNITS >> Student.getGpa()) { while (Student.getId() != id) { outStream << line << endl; } } }
This is what I have right now. It shouldn't be a problem, but for some reason I am getting an error trying to >> Student.getGpa()
Error1error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'double' (or there is no acceptable conversion)c:location1301Project 5
I will post more code if needed, but... I just don't know. I have a TON of code so I would rather not if I don't have to.
Is there a simple notation to check if a value is within a plus or minus range?
E.g. //I read a value A. delay(50); //Read value again -calling this value B delay(50); //Read value again -calling this value C delay(50); //Read value again -calling this value D delay(50); //Read value again -calling this value E Check IF first value A is within 5 of the value B and within 5 of value C, etc.
I can think of a few round about ways of doing this but is there any simple "equals to plus or minus" notation? (what I actually want to do is to check a lot more values than this and it will get very complicated with any of my solutions)....
I just wrote code that is a program for a relativity calculator. However many of my outputs (because the values tend to be large) end up in scientific notation. Although useful, its not great for the laymen, or nice looking.
How can I change it so that output is not in scientific notation? here is the code:
// This program/converter is designed to find the desired 'real' values using Einstein's theory of relativity
Ex. 5 4 + 3 10 * + the answer is 39 because if I change it to infix, it's (5 + 4) + (3 * 10)
I need to use vector to compute the value. Here is what I think. First, I save leftmost from the string. If it is a number, I push. If that is a operation, I pop twice and push the result. By doing it until the string is emptied, the vector will only contain the final answer. And here is my code
#include <iostream> #include <vector> #include <string> using namespace std; int main(){ vector<int> stack; string input;
[Code] .....
When I put 1 1 + or 2 2 +, it showing me a correct answer, but when I put the above example which is 5 4 + 3 10 * +, it shows 30 instead of 39.
I'm trying to make an infix to postfix notation calculator. The difficult thing is th stack class is custom. It's not to hard to understand, I don't know if the fact that it is that way will not allow me to receive support. The difference is that the pop functions is as such:
stack<char> conversion; char temp; conversion.pop(temp);//It receives a parameter and puts the popped element in there. conversion.peek(temp);//Places the top element in said parameter
not only that... but these are boolean functions. they return true if the operation was completed. So they can be used as conditions.
#include<iostream> #include<string> #include<stdio.h> #include"stack.h" using namespace std; int main(void) { Stack<char> conversion; string infix,inter,temps;
[Code] .....
The error is that i am mismanaging parenthesis handling and i can't seem to grasp where and how.
An example input is:(35+7)-(9-2) that input gives me:35 7 + 9 2 ) - but another input such as :(35+7)/7 outputs as: 35 7 + 7 /. Totally fine.
double number = 10000000; int range;//the length of the string result string result;//holds the number in a string ostringstream convert; //stream used for the conversion convert << number; result = convert.str();
range = result.length();
I'm trying to convert a double to a string and when the number goes to ten million it goes to scientific notation and it shows it in the string. How do I stop it from do that?
I was trying 2 write a program that would calculate the sum notation of 1/(i^2) with the starting number to be 1 and goes up to the nth term. For instance if the user inputed 3 then the sum would look like 1+1/4+1/9. I somehow made a code but it gets weird numbers which some include negative numbers... when I input a number that is above 5.
#include <stdio.h> #include <math.h> int main(int argc, const char * argv[]) { int n; register int i=1; float b;//For part 1
[Code] ....
For some reason I can't edit printf("%f",/>/>; when I post it as the topic so ignore that part cuz Ik its supposed to be written as printf("%f",/>;
My code compiled well(After long Messing up with my head). But, i still not satisfied of my output as i expected. My code ought to sort the object of person comparing their salary. But, its not.
Code: #include <iostream> #include <string> using namespace std; class person { protected : string name; float salary;
[Code] ....
It doesn't sort the object of class person rather than it prints out the stored value as it is.
I was having problems changing the value of my head node I passed it as an argument as head which would be the address. The parameter was defined as struct node *head. like this
I tried manipultaing pointer values to change head node value but it did not work. I saw some code online which used pointer to pointers(in code below) to change head node value it worked I dont fully understand why. Would like better understanding of why.
Would also like to know why the argument call needed &head instead of just head.
remove = deleteNode(&head,found); opposed to remove = deleteNode(head,found);
I would like to add a new function to my class, "reverse" that would reverse the order of the list. I have added a prototype in the "public:" section of the code (see the comment with PROTOTYPE in it). Your task is to complete the implementation (see the comment with IMPLEMENTATION in it. See the main() function to see how the results should look
#include #include using namespace std; class List { public: // Constructs an empty list List();
[Code]....
I cant seem to get the right function to put into reverse I have tried everything Im not sure where to start!