473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

write a program that will mimic a calculator

please help me....
using selection structure
the program should take as input two integers and the operation to be performed, iust as it would be entered into a standard calculator. it should output to the screen the same input, including the operator and the result of the operation. example: input2+2, and output 2+2=4
thank.
Mar 12 '07 #1
4 5578
sicarie
4,677 Expert Mod 4TB
please help me....
using selection structure
the program should take as input two integers and the operation to be performed, iust as it would be entered into a standard calculator. it should output to the screen the same input, including the operator and the result of the operation. example: input2+2, and output 2+2=4
thank.
Ok, what do you need help with?
Mar 12 '07 #2
r035198x
13,262 8TB
please help me....
using selection structure
the program should take as input two integers and the operation to be performed, iust as it would be entered into a standard calculator. it should output to the screen the same input, including the operator and the result of the operation. example: input2+2, and output 2+2=4
thank.
You may consider using a switch. So what code have you written so far?
Mar 12 '07 #3
You may consider using a switch. So what code have you written so far?
i only know the flowing. i don't know how to use switch.
Expand|Select|Wrap|Line Numbers
  1. int answer;
  2.     int num1=0;
  3.     int num2=0;
  4.     char ch = ' ';
  5.  
  6.     cout << "Welcome to the calculator" << endl;
  7.     cout << "Enter your equation as number operation number" << endl;
  8.     cout << "(Example: 3 + 4): ";
  9.  
  10.     cin>>num1>>ch>>num2;
  11.          cout<<num1<<ch<<num2<<"="<<num1+num2<<endl;
Mar 13 '07 #4
sicarie
4,677 Expert Mod 4TB
i only know the flowing. i don't know how to use switch.
Expand|Select|Wrap|Line Numbers
  1. int answer;
  2.     int num1=0;
  3.     int num2=0;
  4.     char ch = ' ';
  5.  
  6.     cout << "Welcome to the calculator" << endl;
  7.     cout << "Enter your equation as number operation number" << endl;
  8.     cout << "(Example: 3 + 4): ";
  9.  
  10.     cin>>num1>>ch>>num2;
  11.          cout<<num1<<ch<<num2<<"="<<num1+num2<<endl;
Looks great so far. Did you research the switch statement as r0 suggested?
Mar 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Rafael | last post by:
Hi Everyone, I need some help with my calculator program. I need my program to do 2 arguments and a 3rd, but the 3rd with different operators. Any help would be great. Here is my code.... ...
5
by: simon | last post by:
Hi! I am beginner of VB.net When I wrote with VB6, I copy and paste some same controls, the IDE will paste a assay control such as "label1(1),label1(2)......" . So I can control them total with the...
6
by: trungthanh78 | last post by:
Hello everyone, I'm totally new to the group and I would like to learn from you. Thank you in advance! I need to write a program to track whether a mathematical function has changed during...
1
by: Bl00dFox | last post by:
Hi I am making a simple program to calculate interest. At the beginning when the user has to pick 1 or 2 (to select simple or compound interest respectively), if the user enters a letter (eg, a)...
1
by: d0ugg | last post by:
Hi, I'm did a fraction program for one of my programming classes and it did compile, however when I'm running the program it crashes for some reason that I do not know. // fraction.cpp ...
25
by: mereba | last post by:
Hello My country Ghana is changing its currency. I want to write a small programme in C++ that can covert from the old currency into the new one. I would like this programme to run behind a simple...
3
by: CyBerFirEZ | last post by:
OK, so we have C++ to generate genius programs and perform nightmarish calculations in a second. It's a powerful low level language etc. But the thing is, how do people program other objects apart...
1
by: GEOFRY | last post by:
i m working as a technician at a factory in Kuala Lumpur. my boss need me to make a C program for him. the program that he need is the program that can be like a cashier calculator at...
1
by: chean | last post by:
Write a program that creates a simple calculator . The user enters two numbers in the text fields, Number 1 and Number 2. There are 4 buttons, labeled with “Add”, “Substract”, “Multiply” and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.