$24.99
Programming Assignment 1
ATTENTION:
● Compress all of the Java program source files (.java) files into a single zip file.
● The name of the zip file should follow the below convention:
CS102_Sec1_Asgn1_YourSurname_YourName.zip
● Replace the variables “Sec1”, “YourSurname” and “YourName” with your actual section, surname and name.
Math Problem Solver
The problems to solve are going to use the following templates:
1) Find the prime numbers in the range between X and Y.
2) A rectangular prism volume of dimensions X, Y and Z is to be filled using cube blocks. What is the minimum number of cubes required?
3) What is the area of the union of two rectangles R1 and R2, where top left corner of R1 is (X1,Y1) and its size is (W1,H1), and top left corner of R2 is (X2,Y2) and its size is (W2,H2)?
Implement a menu-driven console application where the user first chooses the problem type, then inputs the problem variables (X, Y, Z, W1, H1 etc.) to get the result of the problem. All variables are going to be integers.
Include an option in your menu to generate N random questions, where N is an integer given by the user. For each question, you should first choose the question template randomly, then randomly generate suitable parameters for that question type. The randomly generated question should have a valid solution. You should also print the answer of each randomly generated question using your implementation.
Sample Output
1. Prime Numbers
2. Volume Filling
3. Union Area
4. Random Questions
5. Exit
Please enter your choice: 1
-Find the prime numbers in the range between X and Y. Please enter X, Y: 5 23
Result: Prime numbers in range [5,23] are 5, 7, 11, 13, 17, 19, 23.
1. Prime Numbers
2. Volume Filling
3. Union Area
4. Random Questions
5. Exit
Please enter your choice: 2
- A rectangular prism volume of dimensions X, Y and Z is to be filled using cube blocks. What is the minimum number of cubes required? Please enter X, Y, Z: 3 6 9
Result: Using cubes of edge length 3 you need 6 blocks minimum.
1. Prime Numbers
2. Volume Filling
3. Union Area
4. Random Questions
5. Exit
Please enter your choice: 3
- What is the area of the union of two rectangles R1 and R2, where top left corner of R1 is (X1,Y1) and its size is (W1,H1), and top left corner of R2 is (X2,Y2) and its size is (W2,H2)?
Please enter X1, Y1, W1, H1, X2, Y2, W2, H2: 0 0 5 10 0 0 10 5
Result: Intersection area is 25 thus the total area of the union is 75.
1. Prime Numbers
2. Volume Filling
3. Union Area
4. Random Questions
5. Exit
Please enter your choice: 4
Please enter the number of questions you want: 4
1) What is the area of the union of two rectangles R1 and R2, where top left corner of R1 is (0,10) and its size is (10,10), and top left corner of R2 is (5,10) and its size is (10,10)?
Result: Intersection area is 50 thus the total area of the union is 150.
2) A rectangular prism volume of dimensions 2, 8 and 6 is to be filled using cube blocks. What is the minimum number of cubes required?
Result: Using cubes of edge length 2 you need 12 blocks minimum.
3) A rectangular prism volume of dimensions 10, 15 and 20 is to be filled using cube blocks. What is the minimum number of cubes required?
Result: Using cubes of edge length 5 you need 24 blocks minimum.
4) Find the prime numbers in the range between 2 and 10.
Result: Prime numbers in range [2,10] are 2, 3, 5, 7.
1. Prime Numbers
2. Volume Filling
3. Union Area
4. Random Questions
5. Exit
Please enter your choice: 5
Goodbye!
Preliminary Submission: You will submit an early version of your solution before the final submission. This version should at least include the following:
• Methods for solving questions templates of 1 (prime numbers) and 2 (volume filling).
• Menu driven console program to get the user’s choice and call the corresponding methods to display the results.
Not completing the preliminary submission on time results in 50% reduction of this assignment’s final grade.