Q3. Programming Task
In this task, you will build a calculator program that will perform the following operations:
• Basic addition (+), subtraction (-), multiplication (*), and division (/) operations
• Calculate the sum of N integers (N < 5)
• Calculate the factorial of the first N integer (N < 10)
The calculator will interface with the end users as follow:
After the program starts, print the following menu:
Welcome to PROG5001 calculator:
*****************************************************************
* Type 1 and press enter to perform basic calculation
* Type 2 and press enter to calculate the sum of N integers (N < 5)
* Type 3 and press enter to calculate the factorial of the first N integers (N < 10)
******************************************************************
Your choice:
After user select option 1 (type 1, press enter), the menu will appear as follow:
Welcome to PROG5001 calculator:
*****************************************************************
* Type 1 and press enter to perform basic calculation
* Type 2 and press enter to calculate the sum of N integers (N < 5)
* Type 3 and press enter to calculate the factorial of the first N integers (N < 10)
******************************************************************
Your choice:1
Input your operator [+.-,*,/] and press enter:+
Input your numbers and press enter:1 2
The result is: 3
Press enter to continue …
After user select option 2 (type 2, press enter), the menu will appear as follow:
Welcome to PROG5001 calculator:
*****************************************************************
* Type 1 and press enter to perform basic calculation
* Type 2 and press enter to calculate the sum of N integers (N < 5)
* Type 3 and press enter to calculate the factorial of the first N integers (N < 10)
******************************************************************
Your choice:2
Input N and press enter:4
Input your first number and press enter:1
Input your second number and press enter:2
Input your third number and press enter:3
Input your fourth number and press enter:4
The result is: 10
Press enter to continue …
After user select option 3 (type 3, press enter), the menu will appear as follow:
Welcome to PROG5001 calculator:
*****************************************************************
* Type 1 and press enter to perform basic calculation
* Type 2 and press enter to calculate the sum of N integers (N < 5)
* Type 3 and press enter to calculate the factorial of the first N integers (N < 10)
******************************************************************
Your choice:3
Input N and press enter:3
The factorial of 3 is: 18
Press enter to continue …
In completion this task, you will demonstrate:
• How to modify the basic calculator class given to you in the first 6 weeks to build this more advanced calculator program.
• How to use Scanner class to handle user input
• How to use basic control structure (condition, loop) to handle the menu system
• How to use array or collection class to store data
Students succeed in their courses by connecting and communicating with an expert until they receive help on their questions
Consult our trusted tutors.