Mathematics Group Assignment
Mathematics Group Assignment
Section 3
Group Assignment
Prepared by:
Code:
#include <iostream>
#include <cmath>
int main ()
{
cout << "Please input the expression\n";
cout << "For example: 2t^3 is coefficient = 2, power = 3\n";
cout << "\n Displacement when t = " << valueT << " is " << answer;
break
; }
else if (equation == 3)
{
//First Integration
coefficient1 = coefficient1 / (power1 + 1);
power1 += 1;
coefficient2 = coefficient2 / (power2 + 1);
power2 += 1;
//Second Integration
coefficient1 = coefficient1 / (power1 + 1);
power1 += 1;
coefficient2 = coefficient2 / (power2 + 1);
power2 += 1;
case 2 : if (equation == 1)
{
// Differentiate the equation
coefficient1 = coefficient1 * power1;
power1 = power1 - 1;
coefficient2 = coefficient2 * power2;
power2 = power2 - 1;
case 3 : if (equation == 1)
{
// First Differentiation
coefficient1 = coefficient1 * power1;
power1 = power1 - 1;
coefficient2 = coefficient2 * power2;
power2 = power2 - 1;
// Second Differentiation
coefficient1 = coefficient1 * power1;
power1 = power1 - 1;
coefficient2 = coefficient2 * power2;
power2 = power2 - 1;
}
return 0;
}
Screenshots of test cases for the possible scenario:
Sample Output 1
V(t) = 6t2 – 4t
6 4
D(t) = t3 - t2
3 2
= 2t3 – 2t2
When t = 5,
D(5) = 2(5)3 – 2(5)2
= 200
Sample Output 3
A(t) = 4t2 – 2t
4 2
V(t) = t3 – t2
3 2
4
= t3 – t2
3
When t = 2,
4
V(2) = (2)3 – (2)2
3
20
=
3
Part 2 Application of Linear Algebra (10 Marks)
Code:
#include <iostream>
#include <cmath>
using namespace std;
int getChoose();
void addition_and_subtraction_of_matrix(int );
void multiply_of_matrix(int );
int main()
{
int pilih, result;
pilih = getChoose();
addition_and_subtraction_of_matrix(pilih);
multiply_of_matrix(pilih);
return 0;
}
}
//Display the result of substract matrix
cout<<"Result: "<<endl;
for(i = 0; i < r1; ++i)
{
for(j = 0; j < c2; ++j)
{
cout<<subtract[i][j]<<" ";
if(j == c2-1)
{
cout<< endl;
}
}
}
}
//If input is not equal to 1&2, user have entered wrong instruction
if (add_or_minus != 1 && add_or_minus != 2)
{
cout<<"You have entered a wrong instruction!"<<endl;
}
}
}
}
if(j == c2-1)
{
cout<< endl;
}
}
}
}
}
}
Screenshots of test cases for the possible scenario:
Case:
Given the individual assessment results of 3 students and the
allocation percentage of each assessment for the course, calculate the
total marks of each student for the course.
Student Quiz Assignmen Proje Exam
t ct
A 80 89 100 92
B 75 80 85 72
C 92 85 78 88
Assessment Allocation
Percentage
Quiz 10 %
Assignment 10 %
Project 20 %
Exam 60 %
Test result:
Success case:
Sample Output 1
1 2 1 0 2 2
Matrix A + Matrix B = [ ] + [ ] = [ ]
3 4 0 1 3 5
Sample Output 2
1 2 1 0 0 2
Matrix A - Matrix B = [ ] - [ ] = [ ]
3 4 0 1 3 3
Sample Output 3
1 2 3 1 0 1 2 2 4
Matrix A + Matrix B = [4 5 6] + [0 1 0] = [4 6 6]
7 8 9 1 0 1 8 8 10
Sample Output 4
1 2 3 1 0 1 0 2 2
Matrix A - Matrix B = [3 4 5] - [0 1 0] = [3 3 5]
5 6 7 1 0 1 4 6 6
Sample Output 5
1 2 3 1 0 0 2 2 3
Matrix A + Matrix B = [ ] + [ ] = [ ]
4 5 6 1 1 0 5 6 6
Sample Output 6
1 2 3 1 0 0 0 2 3
Matrix A - Matrix B = [ ] - [ ] = [ ]
4 5 6 1 1 0 3 4 6
Sample Output 7
1 0
1 2 3
Matrix A × Matrix B = [ ] × [0 1]
4 5 6
1 0
(1 + 0 + 3) (0 + 2 + 0)
= [ ]
(4 + 0 + 6) (0 + 5 + 0)
4 2
= [ ]
10 5
Error case:
Sample Output 1
1 2 3
Matrix A + Matrix B = [ ] - [3 2 1] = ERROR!
4 5 6
Sample Output 2
1 2 3 7 8 9
Matrix A × Matrix B = [ ] × [ ] = ERROR!
4 5 6 1 0 0