C++ :: Make Different Type Of Calculator Out Of Boredom

Feb 10, 2014

ive been learning from the book for 4 days and decided to make a different type of calculator out of boredom but im really having problems when i try to make it a loop? ive been scratching my head trying to work it out rewriting deleting etc but cant work it out

Code: #include <iostream>
#include <string>
using namespace std;
int main()

[Code].....

View 9 Replies


ADVERTISEMENT

C# :: Calculator - How To Make Backspace Button

Jul 21, 2010

I'm making a calculator project but i can't find a solution for backspace button ,, i used these code -->

TxtNumber.Text.Remove(0,1);

But it removed the first number i wrote in the TxtNumber(TextBox) not the last one !!!!

View 6 Replies View Related

C++ :: Reverse Polish Calculator - How To Make Program Exit If User Enters Only 0

Oct 11, 2013

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;

class Stack {

[Code] .....

View 1 Replies View Related

C/C++ :: Parking Garage Cost Calculator Based On Type Of Vehicle And Time

Nov 3, 2014

There are a few functions for this code and I am not very good with functions yet(we just learned about them last week).

//This program will calculate the cost of using a parking garage
//based on the type of vehicle and the time of parking.
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<string>
using namespace std;
//define rates

[Code] ...

Error List:

Error1error C2100: illegal indirectionc:userscodydesktopgaragecodegaragecodesource.cpp971GarageCode
Error2error C2100: illegal indirectionc:userscodydesktopgaragecodegaragecodesource.cpp1051GarageCode
Error3error C2561: 'main' : function must return a valuec:userscodydesktopgaragecodegaragecodesource.cpp1161GarageCode

[Code] ....

View 2 Replies View Related

C++ :: How To Make A Type Based On A Value

Jul 10, 2012

Another fun question... Is it possible to make a type, based on a value ?

What I'm looking for is way to return the smallest (sizeof) unsigned integral type that will hold a certain value.

smallest_type<14>::type // unsigned char
smallest_type<127>::type // unsigned char
smallest_type<255>::type // unsigned char
smallest_type<256>::type // unsigned short
smallest_type<64000>::type // unsigned short
smallest_type<128000>::type // unsigned long
smallest_type<5000000000>::type // unsigned long long

View 3 Replies View Related

C++ ::  make Program That Can Type String Into Another Window?

Apr 26, 2013

I am trying to make a program that can type a string into another window. I have gotten it to the point that it can type the string, just not correctly. It will type random numbers and not the given string. The key event uses ASCII code for the arguments, and I don't see anything wrong with my numbers. Here is the code I have so far.

#include "stdafx.h"
#include <iostream>
#include <windows.h>

[Code].....

View 2 Replies View Related

C++ :: Can Use Templates To Make A Multi-type Linked List?

Apr 28, 2014

If I wanted an int connected to a float connected to a string connected to a POD, would all I have to do is :

Code:

template<class T, class X>
struct node {
T data;
node<X> *next;
};

Or would I be forced into using polymorphism?

View 10 Replies View Related

C++ :: Changing Array Of Numbers Of Type Char To Type Int?

Apr 27, 2013

I'm having some problems with changing an array of numbers of type char to type int. Every time i try to sum 2 array indexed values it returns some letter or symbol. Also, if i change the type of the array in the functions the compiler gives me an error message. I would also like to add that the problem requires that the first two arrays be char so each individual number gets assigned to a different value.

My current code is:

Code:
#include <iostream>
void input(char a[], char b[], int& size_a, int& size_b);
void convert(char a[], int size);
void reverse(char a[], int size);
void add(char a[], char b[], int c[], int size);
int main()

[Code]....

View 4 Replies View Related

C++ :: Convert Element Of Int Type Of Array To Char Type?

Dec 21, 2013

how to convert an element of int type of an array to char type?

View 2 Replies View Related

C++ :: Determine If Type Is Of More Derived Type Than Another At Runtime

Aug 31, 2014

I have a function like this:

template<typename T>
void f() {
//...

[Code]....

list contains, in order: A, B and C in any order, D, E

I am thinking it is possible with some clever template and polymorphism combos, but maybe not. As a last resort I know how to make it work by storing static type information in each class, but I'd like to avoid that if possible.

View 6 Replies View Related

C++ :: Write A Calculator Using Two Stacks

Apr 13, 2014

I just started by defining a stack class (stackDouble). I need to write a program that accepts an infix calculator expression, with the following operators (**, exponentiation, /, division, and, -, subtraction. The operator precedence is exponent, division, and subtraction.I need to use a stack of doubles and a stack of strings, of which I can write two classes, or write a single stack template. The user will input the expression just via cin, and there will be a # before every number, a ! before each operator, and a . at the end of the expression. '#', '!', or '.' can be input into a char variable, numbers into a double variable and operators into a string variable.

For example, the following would output 6:

# 3 ! / # 2 ! / # .5 ! ** # 2 .

As stated above, I already made up a stackDouble class. What would I need to do to create the other class (I don't think I want to do it with a template)?

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

[code]....

View 2 Replies View Related

C :: BMI Calculator With Added Function

Aug 17, 2013

getting error with gcc under OSX.

Code:

/* bmi2.c */
#include <stdio.h>
main()
{
float height, weight;

printf("Enter weight:
");

[code]....

View 2 Replies View Related

C :: Calculator Using Mouse With A Bug While Dragging

Mar 6, 2015

I have an assignment to do a calculator in C, wich will work by clicking the numbers with the mouse, however i have a bug that when i hold the mouse and dragg it, it assumes that I'm clicking multiple times, also, when I click in an empty space the program creates a blank space on the calculator screen.

Code:

#include <stdio.h>
#include <conio.h>
#include <math.h>
#include "..MouseHandler.h" // ajustar o caminho ao seu projecto
#include "..calcSkinLib.h" // ajustar o caminho ao seu projecto
#define PI = 3.1415;

[code]....

View 2 Replies View Related

C++ :: Creating Exact Age Calculator?

Aug 3, 2014

I've been wondering this, since there is so many things which needs to be taken care of. I created one, but it wasn't precise.

View 19 Replies View Related

C/C++ :: GPA Calculator With Text File?

Mar 5, 2015

I'm trying to create a program that will calculate the gpa of several different students, whose data are in a text file. The file looks something like this, with possibly more lines.

Mark 3 4 A 3 D 2 C 1 A
Tom 2 3 A 2 C

The very first number tells us how many credit hour/grades will follow. I have a couple of problems though: From the code I've written I don't seem to get any data other than the first line. Also the gpa that does print out after the file runs is just a 0.00, rather than the actual gpa.

#include<stdio.h>
int main(void)
{

[Code].....

View 6 Replies View Related

C/C++ :: Error When Trying To Program BMI Calculator

Aug 26, 2014

'm trying to program a BMI calculator in C for my assignment where the weight must be in KG and an int , and the height must be in m and a double value. The program should allow the user to input his weight(kg) and height(m) separated by a space and be able to calculate and display the BMI. My code is shown below :

#include<stdio.h>
int
main(void) {
int weight;
double height,bmi;
bmi = weight / ( height * height ) ;
scanf("%d%lf" , &weight , &height );
printf("BMI = %f", bmi);
return 0;
}

However , after running the program , I constantly get a 1.#INF00 value for my result.The compiler did not show any errors so why I'm getting this value.I input my weight and height in this format "45 1.65" 45 being the weight and 1.65 being the height.

View 3 Replies View Related

C/C++ :: Calculator That Uses Only Getchar / Putchar

Mar 24, 2014

I basically just have to make a calculator that only uses getchar/putchar (printf is Ok for displaying errors) - Also, negatives must be error-checked. As of right now, my program will only work if there is exactly one space between the number, operand, and other number. No spaces, or more than one space, will give me some very weird digits. I also need to display the numbers with putchar, and not printf (as I did below), but I just really wanted a working program.

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
int add(int input1,char operand, int input2);
int subtract(int input1,char operand, int input2);

[Code] .....

View 12 Replies View Related

C/C++ :: Area Of Triangle Calculator?

Nov 16, 2014

I was asked to build a small program to calculate the are of a Triangle but my code must have some problem.. />

#include "stdafx.h"
void main()
{
int a,b;

[Code]....

I get this errors:

-warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

-warning C4244: '=' : conversion from 'int' to 'float', possible loss of data

View 4 Replies View Related

C++ :: Calculator Using Pointer Does Not Work

Jan 18, 2015

I am making a calculator where I will input 5 array of numbers and calculate those numbers with pointers or whatever you call it. I am getting an error like

note C:Dev-Cppincludec++3.4.2itsostream.tcc:63 candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]

and more error if I try to fix the code. So yeah, can i have a hand?

Btw, here's my code.

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
using namespace std;
// function declaration:
void getAverage(int*);
void getSum(int*);

[Code] .....

View 7 Replies View Related

C/C++ :: Adding Calculations To BMI Calculator

Oct 8, 2014

I have to enhance my BMI program to tell whether the person is at optimal weight, under weight, or overweight and I cannot find the correct calculation. Here is the code I have so far that works for calculating the BMI.

namespace Body_Mass_Index {
public partial class BMI_HW : Form {
public BMI_HW() {
InitializeComponent();

[Code] ....

View 14 Replies View Related

C++ :: How To Use Type RectangleF As Built In Type

Jul 22, 2013

I need to use the type RectangleF as a built in type in c++ ie I need to declare a variable rect as RectangleF rect;

what do I have to include to be able to do this.

View 2 Replies View Related

C :: Calculator - Input Specific Number?

Feb 11, 2013

In my calculator, I am trying to make it so that you put enter 1 to add, 2 to subtract, 3 to multiply, and 4 to divide. I am facing the issue of making it so that you must enter a number, however instead of it being any number, it must be 1, 2, 3, or 4, and if it is not any of those numbers, you must re-enter the number. Here is a little snippet of my code:

Code:

printf("Please enter 1 to add, 2 to subtract, 3 to multiply, or 4 to multiply: ");
while (scanf("%d", &input) != 1) {
while (getchar() != '
');
printf("Invalid option. Please try again: ");

[Code] ....

how I can make the loop affect specific numbers.

View 4 Replies View Related

C :: Calculate Equations Just Like A Standard Calculator

Oct 23, 2013

The main point of the program is to calculate equations just like a standard calculator but I wanted to do it myself. I don't understand what the problem is right now but I've managed to create a program that asks for both values but somehow it doesn't want to ask for an operator (*, /, + etc). What's wrong with my code that the terminal skips the scanning part for the operator?

Code:

#include <stdio.h>
int main() {
int value1, value2, answer;
char operator;

[code]....

View 12 Replies View Related

C++ ::  Calculator Program - Function Does Not Take 0 Arguments

Jan 29, 2014

I am supposed to get 2 numbers then have the person choose what they want to do to the numbers. Here is the code:

//Mike Karbowiak
//12/24/13
//Mathematics
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>

[Code] ....

The errors I am getting so far are:

error C2660: 'Add' : function does not take 0 arguments
error C2660: 'Subtract' : function does not take 0 arguments
error C2660: 'Multiply' : function does not take 0 arguments
error C2660: 'Divide' : function does not take 0 arguments

View 3 Replies View Related

C++ :: Generic Shape Area Calculator

Dec 6, 2013

I'm building a pretty basic calculator program that calculates the area of generic shapes (triangles, rectangles, and squares); for some reason though, my program is having troubles as soon as it hits the if/else code in the int main section. When I enter triangle, rectangle, or square, it just spits back out the "That's not one of the options. Please re-enter and try again." error line I created. When I isolate and run just the stuff inside the if/else statements it works great, but why it won't just understand my if (shape == triangle).... .

Code:

#include <iostream>
using namespace std;
class figure {
protected:
double x, y;

[Code] ....

View 2 Replies View Related

C++ :: Cone Volume Calculator Program

Nov 6, 2014

I'm working on below program and I want the program to do the same thing, but with not one main() function, but instead one main() function PLUS one user defined function called computeConeVolume that contains the calculation. In other words I want to remove the one line calculation and replace it with a function call, then write and add the function below main with the calculation, surrounded any other syntax that I need to complete it.

The function should contain local variables and a constant declared and must have the calculation, it may not do anything else such as input or output. Should be able to declare "global" variables anywhere but no variables above or outside of main() and the function are allowed. A value-returning function should be used because it's a little simpler to understand, but you can employ a void function. Need to have a function prototype at the top of the code, then main, then your function.

//Cone Volume Calculator Program
#include <iostream>
using namespace std;
int main( ) {
//Declare variables and constants
double coneRadius = 0.0;
double coneHeight = 0.0;

[Code] ....

View 6 Replies View Related







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