5 喜歡 0 不喜歡
97 瀏覽

We need to build a program that performs 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
[正常] Coding (C++) - 最新提問 分類:Introduction to Computer Programming I (C) | 用戶: (9.9k 分)
ID: 25997 - 從幾時開始: 無限制 - 到幾時結束: 無限制

標籤修改 用戶: | 97 瀏覽
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.158.78.225
©2016-2024

相關問題

6 喜歡 0 不喜歡
2 回答
[正常] Coding (C) - 最新提問 10月 16, 2017 分類:Introduction to Computer Programming I (C) | 用戶: thopd (12.1k 分)
ID: 27175 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 205 瀏覽
12,783 問題
183,443 回答
172,219 留言
4,824 用戶