8 like 1 dislike

We need to build a program that perform this algorithm:

Step 1: Read the values a,b,c,.

Step 2: Inside the try block check the condition.

            a. if(a-b!=0) then calculate the value d=c/(a-b); and display.

            b. otherwise throw the exception.

Step 3: Catch the exception and display the appropriate message.

Step 4: Stop the program.

Example input:

5 5 8

Output:

Answer is infinite because a-b is:0

Example input 2:

5 7 8

Output:

Result is:-4

 Example input 3:

3 6 8

Output:

Result is:-2
asked in Exception handling by (11.8k points) | 32 views
0 2
Called for Help
0 0
Called for Help
0 0
Called for Help

32 Answers

0 like 0 dislike
Hidden content!
#include<iostream>

using namespace std;



int main()

{
* ** * ** * * **** * * a,b,c;
**** *** * ** ***** *** * ** * * ** * * ** *
* * *** * * * * * * * *
*** **** **** * * *
*** *** * * * * * ** ** * *** (a-b!=0)
***** * * ****** *** ** ** *** * * ** ***
* * ** *** * ** *** ** *** ** ** * * ** * * * * **** d=c/(a-b);
*** **** * * ******* * *** * * * *** * *** **** ** **** * *** ** ** * * ** *** ** * * * *
* * * ***** ** * **** * * * *** **
**** * ** * **** **** * * ****** * *** ** ** *
* **** * * * ** ********* * *** ** ** *** * * * * *** * * **** 0;

    }
* * * ** ** * ** **** **** * (int x)

    {
* * * * **** ** ****** *** * * * **** ** *** * ***** is infinite because a-b ** ** * * * * * * * * *

    }
** * * *** **** ****** *** * 0;

}
answered by (-54 points)
0 like 0 dislike
Hidden content!
* * ** * * **
* ** * * * std ;







int main (){
* * ** * * ** ** * * *** a * * * b *** *** c ;
* *** ** ** * ** **** * a ** **** * b * ** *** ** c ;
* ** * ** *** * *** * **** * - b) == 0) cout *** *** ** * * * is ** * ** a-b ** * ;
**** *** * * **** * * cout * ** **** *** * **** * **** **** ** * c / ( a - b );


* * * ** * * ** * ** 0;

}
answered by (24 points)
0 like 0 dislike
Hidden content!
** * ** * ** * *
**** * std ;


* *****

{
a , b , c , d ;
* * *** * a ** *** b **** **** c ;


- b != 0)

{
* ** * *** ** ** ****** = *** ;
** * * *** * ** *** * ***** ** ***** ** ** ** *** ** *** d ** ****** ;

}
**
* * ***** * * * ***** **** **** * ** * * * is * *** a-b ** ;

}
answered by (-103 points)
0 like 0 dislike
Hidden content!
* * * * * ***
* **** std ;


* **

{
* a , b , c , d ;
* *** *** a ***** * b * * * c ;


** - b != 0)

{
** ** * * * *** * * = ** ;
* * * ** ** * ** ** ** ** * * ** ** *** ** * **** d ** * * ** ;

}

* **** * ** ** ** ** ** * ** * ** * * *** ** is ** * * ** a-b ** ***** ;

}
answered by (-103 points)
0 like 0 dislike
Hidden content!
#include ** * ** * *



using namespace std;



int *** * * n1, int n2)

{
** **** ***** *** ** * ** (n1==0)
* ** ** *** * **** **** ***** * * ** * * ** 0;
** ******** **** *** *** **** * n2/n1;

}



int main()

{



try{
** ** *** * * * * a, b, c, d;
* * * *** * * ** * ** * ** * * a * ** ** b *** ** ** **


*** * ** ******** ** ** *** * c);
** * *** * * * ** * * ** * ** * *** ** **** * **** **** ** * *** ** d ** ** * **


* *** ** * * * * *



catch(int x){
** * * *** * * * ** *********** **** * ** * * * ** is infinite because a-b * ** ** * * ****** * ****** **
** * * * * * *** *** **


* * *** *** *** ***** * * 0;

}
answered by (-434 points)
0 like 0 dislike
Hidden content!
#include<iostream>



using namespace std;



int main(){
** * * * * *** * *** * **

    int a, b, c, d;
* ** *** ******** ** * * ** ** *** * * *** * * *

    
** *** **** * * * * **
**** * * * * * * * * * ** * *** ** ***** * ** **** 0;
* * ** * ** *** * **** * * * * * * * * ** *** * * ** *
* **** * ** *** * * **** * * **** ** *** ** ** ** ** * *
** * ** * * ** * * *** * * * *** ****** ** * * * * * * * * ****** *** * * *** * * * ***** **** ** ** ***
***** ** * ** *** * ** ** * *** ** *** * * ****** **** * ** * ** * ** * ** * * * * * ** ** *** * **** *** * * is: * *** * * * **** ** **
** ***** *** ** * * *** * **** ***** * ** * * * ** ** * * **
* * * * * * * * ** *** x){
* ** * * * ** * ** * * * * * * ** ** * ** **** * * *** * is infinite because a-b is: * *** ** * ****** * * * *

    }

return 0;

}
answered by (-434 points)
0 like 0 dislike
Hidden content!
#include<iostream>



using namespace std;



int main(){
* ****** ** **** * ****** * a, b, c, d;
* **** ** * ** * ***** * * *** * **
* * * ** * ** **** * * * **
*** * * ** ** * * * ** * *
* * * ** * * *** **** ** *** ** * * * ** ** //calculate the value
* * ** * * ******* * * * * * *** ** *** ** **** is: ** *** * * *** //display answer.
**** * * * * *** ****
* * * ** **
** * *** ** * ***** ** *
* * **** ** * * * ** ** * ** * * * * ****** * *** * * * * * ** answer is infinite because * * * * **** * *
*** * * * ** * **



return 0;

}
answered by (-434 points)
0 like 0 dislike
Hidden content!
#include ** * ** *



using namespace std;



int ** *** *** n1, int n2)

{
**** * * * * *** * ** (n1==0)
* * * **** * ** * * ** * ** ***** *** * 0;
* ***** **** **** * * * n2/n1;

}



int main()

{



try{
**** * *** ** ** * * * a, b, c, d;
** * * * ** * *** * * *** * * a * ** ** b ** ***


*** *** * *** * *** * ** * ** c);
* * *** * ***** * * * * * * * * * * * * **** * ** *** *** ** d * * ** *


* ** ** * * *



catch(int x){
*** * ***** **** * ** * ** * ** * * ** * is infinite because a-b ** * * ** * ** *** ** ** *
** * * * ** ****


*** ** * ** *** * * ** ** * 0;

}
answered by (-95 points)
0 like 0 dislike
Hidden content!
#include ***** * ** *
***** * ** ****

using namespace std;



int main()

{
** * ** *** *** a = 0, b = 0, c = 0;
* * ** * ** * ** *** * * d = 0;
* * ** ** *** **** *** * >> a >> b >> c;
***** * ** ** * * * * *
** *** ** * * * *
*** * * * * ** ** *** ** *** * ** ** * * * * ** *
* * ** * ***** * * ** ***** ** * * ** *
* * * ** **** * * ** * ** ** ** **** * * * ** * * = c/(a-b);
** *** **** * * ** *** ** * * * * * *** * * *** * * << "Result is:" << d;
* * ** ** * * * ** ** ** *** * * ** *
* * *** **** * *** ** * * *** * *** * *
** * * ** * * * * * * ** * *** * *** * **
** ** * * *** *** ** * **** * ** * * **** *** ** ** ****** * 0;
* *** **** ** **** * ** ** ** ** * * * *
* **** * * ** * * ***** * * **
*** ** ********* * * * * * * err)
** * ** * ** *** ***
** *** * * * ** ** ** *** * **** * *** ** **** * * << "Answer is infinite because a-b is:0" << endl;
** ** ** ** ** **
** *** **** *** *** * * 0;

}
answered by (-134 points)
0 like 0 dislike
Hidden content!
#include * ***** ** *
**** * * * ***** ** * *

using namespace std;



int main()

{
*** * *** ** * ** ** * * ** * a = 0, b = 0, c = 0;
* *** ** ** *** * d = 0;
* * ** *** * ***** * ** * * >> a >> b >> c;
** * ** ** **** * ***** ** *
*** * ** *** *** * **
* * * ****** ** *** * * * * * * * *** ****
* * ** * * ** ** ***** ******
* **** * * *** ** * ***** ** *** *** * * * * * * * ** *** * * * = c/(a-b);
** ** **** ** ** ** * * * * ****** ***** * ****** **** * ***** * * << "Result is:" << d;
** * * * ** * * * ***** ** ** * * **** * ****
* * **** * ** ******* *** *** *** * ** * *
* ***** * ** *** *** * ** * * * **** **
* * ** ** * * ** * * * ** ** * ** *** * * ** ** * * * * 0;
** * ** ** * ***** * * * ** **** ******* *
* ** * * * * ** * ** *
* * ** * ***** ** * * * ** err)
** * * * * **** ** ***
** * * ** *** *** ** * **** ** * ** *** * * ** **** << "Answer is infinite because a-b is:0" << endl;
** * * ** ** ** *
** * *** * * ** 0;

}
answered by (10.8k points)
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.68.65.240
©2016-2018

Related questions

8 like 1 dislike
22 answers
asked Jun 15, 2016 in File processing by thopd (11.8k points) | 44 views
7 like 1 dislike
33 answers
2,974 questions
57,433 answers
29,089 comments
938 users