Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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
  • 876 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
  • 876 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