Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

 

 

INSTITUTE OF COMPUTER SCIENCE AND DIGITAL INNOVATION 

BIC 1114: INTRODUCTION TO PROGRAMMING

 

 

INSTRUCTIONS TO CANDIDATES

 

1. This assignment will contribute 25% to your final grade.

 

2. This coursework is a group assignment. You may have maximum 2 members in one group.

 



 

Instruction

 

The program reads an arithmetic operation when the user keys in one of the following valid forms: a + b; a - b; a * b; a/b

where a and b can be either positive or negative integers. There may be spaces or no space between ‘a’ and a valid arithmetic operation and also similarly between the valid arithmetic operation and b. Some valid examples are given below:

 

a + b, a + -b, a+ -b, a +-b, a+-b

 

-a + b, -a + -b, -a+ -b, -a +-b, -a+-b

 

a - b, a - -b, a- -b, a --b, a--b

 

-a - b, -a - -b, -a- -b, -a --b, -a--b a * b,  a * -b,  a* -b, a *-b, a*-b

-a * b, -a * -b, -a* -b, -a *-b, -a*-b a / b, a / -b, a/ -b, a /-b, a/-b

-a / b, -a / -b, -a/ -b, -a /-b, -a/-b

 

 

 

Since this is the first programming assignment that some of you are developing a solution for the first time, I have broken down the program assignment into several parts to make it easier to develop and to better understand the program solution for each part. The development of a program solution for each part will offer great insights on how the program instructions were stitched together to create the solution for that part.

 

The developed solution for each part should be used in developing the program solution for the next part of the program assignment. In doing so, you will learn on how to make the necessary changes to the previous developed solution that eventually leads to the correct solution for the part you are working on.

 

 

Part 1 (35 Marks):

 

This programming assignment assumes ‘a’ takes either positive or negative integer value while b takes only positive integer value. After removing spaces in the valid arithmetic operation which will then take the form of

 

a+b, a-b, a*b and a/b

 

-a+b, -a-b, -a*b and a/b


Note there are No spaces between a and the sign operation and also sign operation and b. Assume that all input entries by the user are valid.

 

 

An important function in the developed program solution is testing. Your program should test for all possible valid data entries.

 

In submitting your solution show proof, your program worked for all valid data entries. Use the following test cases:

 

1) 823 + 145

 

2) -23 + 245

 

3) -23 *45

 

4) -23 / 345

 

5) -23 -45

 

 

 

The grading will check for the correctness of the program together with the comments showing the program flow (30 Marks) and test results (5 marks).

 

 

Part 2 (65 Marks):

 

After having successfully implemented the solution for part 1, you are now required to make changes to your developed program in part 1 to detect any non-valid arithmetic operations by informing the user “it’s an invalid arithmetic operation” and prompting the user to retry. A maximum of three tries are given to the user and the program terminates when the user exceeds the number of tries.

 

The valid input arithmetic operation is of the form given below: a + b, a + -b, a+ -b, a +-b, a+-b

-a + b, -a + -b, -a+ -b, -a +-b, -a+-b

 

a - b, a - -b, a- -b, a --b, a--b

 

-a - b, -a - -b, -a- -b, -a --b, -a--b a * b,  a * -b,  a* -b, a *-b, a*-b

-a * b, -a * -b, -a* -b, -a *-b, -a*-b a / b, a / -b, a/ -b, a /-b, a/-b

-a / b, -a / -b, -a/ -b, -a /-b, -a/-b


Your program should test for all possible valid data entries and invalid ones too. In submitting your solution show proof, your program worked for all valid and invalid cases.

 

Test Cases:

 

Valid Cases:

 

1) 823 + -145

 

2) -23 + -245

 

3) -23 *-45

 

4) -23 / -345

 

5) -23 --45

 

Non Valid Cases 1) --23 + 45

2) -23 +* 45

 

3) -23 +/ 45

 

4) -23 -/ 45

 

5) -23 */ 45

 

6) --23 */-45

 

7) -23 -+ 45

 

8) 23 ++45

 

9) 23 **5

 

10) 23 // 42

 

12) 23a + 67

 

13) 23 ab 67

 

14) 23 + 67k

 

15) a23 + 67

 

The grading will check for the correctness of the program together with comments showing the program flow (45 Marks) and test results (20 marks).