- #1
mgc
- 3
- 0
For the purposes of this problem we will define a large number as a positive whole number with at least eight digits. For example, 123456789 is a large number. Large numbers must NOT be expressed in exponential form.
Write a program that:
(1) asks for two inputs.
WHAT IS THE FIRST LARGE NUMBER?
WHAT IS THE SECOND LARGE NUMBER?
and
(2) then calculates the product of your two large numbers and prints;
THE PRODUCT OF your first large number
AND your second large number
IS the calculated product.
Test your program with 1234512345123451234512345 as your first large number and 9876598765987659876598765 as your second large number.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include<iostream>
#include<iomanip>
using namespace std;
void main()
{
string first, second,
long int answer = 0;
char ans;
bool again = false, ans2 = false;
do {
again = false;
cout<<"Enter the first LARGE number: ";
cin>>first;
cout<<"Enter the LARGE second number: ";
cin>>second;
if (first < 10000000)
{
cout<<"\nOne of the numbers is not 8-digit long. Try again.";
again = true;
cout<<endl;
}
} while (again);
answer = (int) first * (int) second;
cout<<"\n\nThe calculated product of "<<first<<" & "<<second
<<"is "<<setw(16)<<answer;
do{
cout<<"\nDo you want to try again? [Y/N]: ";
cin>>ans;
switch(ans)
{
case 'Y':
case 'y': ans2 = true; break;
case 'N':
case 'n': exit(1); break;
}
/*if
cout<<"Invalid Input. Try again."*/
} while (ans2);
}
can you correct this?
Write a program that:
(1) asks for two inputs.
WHAT IS THE FIRST LARGE NUMBER?
WHAT IS THE SECOND LARGE NUMBER?
and
(2) then calculates the product of your two large numbers and prints;
THE PRODUCT OF your first large number
AND your second large number
IS the calculated product.
Test your program with 1234512345123451234512345 as your first large number and 9876598765987659876598765 as your second large number.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include<iostream>
#include<iomanip>
using namespace std;
void main()
{
string first, second,
long int answer = 0;
char ans;
bool again = false, ans2 = false;
do {
again = false;
cout<<"Enter the first LARGE number: ";
cin>>first;
cout<<"Enter the LARGE second number: ";
cin>>second;
if (first < 10000000)
{
cout<<"\nOne of the numbers is not 8-digit long. Try again.";
again = true;
cout<<endl;
}
} while (again);
answer = (int) first * (int) second;
cout<<"\n\nThe calculated product of "<<first<<" & "<<second
<<"is "<<setw(16)<<answer;
do{
cout<<"\nDo you want to try again? [Y/N]: ";
cin>>ans;
switch(ans)
{
case 'Y':
case 'y': ans2 = true; break;
case 'N':
case 'n': exit(1); break;
}
/*if
cout<<"Invalid Input. Try again."*/
} while (ans2);
}
can you correct this?