got my first HW on the first day of class, have no idea of what to do, please help me!!!!
The HW question is this
write a program that will act as an interactive calculator capable of handling very large (larger than the largest long integer) nonnegative integers. this calculator need perform only the operations of addidtion and multiplication
in this program, each input line is of the form
num1 op num2
and should produce output such as
num1
op num2
-------------
num3
where num1 and num2 are(possibly very large) nonnegative integers, op is the single character + or *, and num3 is the integer that result fromt he desired calculation.
Program 1
Write the interactive calculator described in Programming Problem 5 on page 64 of the text.
· Do not use classes. Do use an appropriate typedef for your long numbers.
· Do use fixed-length arrays to store the digits of the long numbers the program manipulates.
· Ignore the optional part of the problem.
· Assume there is at least one space between each number and the operator symbol. Of course there will not be spaces between the digits in a number (i.e. 123, not 1 2 3).
· Do not implement multiplication. If the operator symbol is *, have the output indicate that multiplication is not yet implemented.
· Be sure to follow the guidelines given in the programming standards document on this course website.
Just to be clear, input to the program should look like this:
000655123897667676422 + 21346615433431
or like this:
564557655123897667676422 * 77621346615433431
Of course, in the second case, the program just says that it can't yet handle multiplication.
what I had though is to use 4 array, 3 that hold the numbers, and one that hold the sign, but I dont know how to write an array plus another array and save it to another array. plese help, here's the code that I had try
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
const int arraysize=30; //an array of could hold up to 30 characters
typedef char string; //defind string as char data type
string num1[arraysize]; //array to store first set of numbers
string sign[arraysize]; //array to store the operation sign
string num2[arraysize]; //array to store second set of numbers
string num3[arraysize]; //array to store the answer
cin>>num1>>sign>>num2;
num3=int(num1-'2')+int(num2-'1');
cout<<num1<<endl<<sign<<num2<<endl<<--------<<num3<<endl;
return 0;
}