Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

calculator


  • Please log in to reply

#1
lilhawk2892

lilhawk2892

    Member

  • Member
  • PipPipPip
  • 128 posts
ok after looking i have a hard time reading this so here is an updated version


Im making a calculator.I think the formula is easy,x+y = answer.But im having a problem.How do i make the value of x the first number the user put in,and the value of y the second number the user put in. so can anybody help me

Edited by lilhawk2892, 17 August 2005 - 01:07 PM.

  • 0

Advertisements


#2
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 875 posts
you need a cin for x and a cin for y.

you will need a switch statement - so go back to the tutorials for switch().

when you are done you will have

double add( double x, double y ) { ... }
double sub( double x, double y ) { ... }
double mult( double x, double y ) { ... }
double div( double x, double y ) { ... }

don't forget to check for dividing by zero.

remember - when all else fails, google on calculator c++ !!!!!!!!!
  • 0

#3
lilhawk2892

lilhawk2892

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 128 posts
thanks and looks like im nowhere near making a calculator i havnt gotten close to swith statements yet
  • 0

#4
chickenman

chickenman

    Member

  • Member
  • PipPip
  • 37 posts
@bdlt
Who do you have to make things sound so hard

@lilhawk2892
here is a simple calculator to add two numbers

#include <iostream>
using namespace std;

int main()
{
double a;
double b;
double total;
cout<<"Enter first number" << endl;
cin >> a;
cin.ignore();

cout<<"Enter second number" << endl
cin >> b;
cin.ignore();

total = a + b;
cout<<"The total of " a  " + "  b "  is  " total << endl;
cin.get();
return 0;
}

  • 0

#5
lilhawk2892

lilhawk2892

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 128 posts
18 C:\Dev-Cpp\main.cpp expected `;' before string constant


can u pls fix it i really dont know where to put it
  • 0

#6
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 875 posts
the compiler found a problem with line 18.

18 C:\Dev-Cpp\main.cpp expected `;' before string constant


look carefully at line 18

cout<<"Enter second number" << endl

do you see anything missing?
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP