Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*** These are the solutions to the C++ practicals given to us. Feel free to copy and run the code on your systems, but make
- sure to choose different values as your input at runtime and if possible interchange the variable names.
- Please if you notice any bugs or errors kindly let me know.
- NB: Will try to finish up the remaining weeks ASAP.
- Author: Isaac Adepitan Oluwatoyin
- Mail: isaacadepitan@gmail.com
- ***/
- Week 1 Solution
- //Program to calculate 25% payrise of employees for 7 months
- #include <iostream>
- using namespace std;
- int main ()
- {
- float asalary, msalary, bdpay, bdpay7;
- float payrise = 0.25;
- cout << "Enter your Total Salary for last year" << endl;
- cin >> asalary;
- msalary = asalary / 12;
- cout << "Your monthly salary is: " << msalary << endl;
- bdpay = msalary * payrise;
- cout << "Your total 25% increase per month is: " << bdpay << "%" << endl;
- bdpay7 = 7 * (msalary + bdpay);
- cout << "Your total 25% increase for 7 months is: " << bdpay7 << "%" << endl;
- return 0;
- }
- Week 2 Solution
- //Program to Calculate Principal and Interest rate for three years
- #include <iostream>
- using namespace std;
- int main()
- {
- float principal, ainterest, interesty1, interesty2, interesty3;
- float arate = 0.1475;
- cout << "Enter the principal amount you invested: " << endl;
- cin >> principal;
- ainterest = principal * arate;
- cout << "Your Annual interset is: " << ainterest << endl;
- interesty1 = principal + ainterest;
- cout << "The Balance for Year 1 is: " << interesty1 << endl;
- interesty2 = interesty1 + ainterest;
- cout << "The Balance for Year 2 is: " << interesty2 << endl;
- interesty3 = interesty2 + ainterest;
- cout << "The Balance for Year 3 is: " << interesty3 << endl;
- cout << "The Amount Invested was: " << principal << endl;
- cout << "The Total Balance for Three Years is: " << interesty3 << endl;
- return 0;
- }
- Week 5 Solution
- //Program to find the sum and product of two numbers
- #include <iostream>
- using namespace std;
- int main()
- {
- int a, b, sum, product;
- cout << "Enter First Integer NUmber: ";
- cin >> a;
- cout << "Enter Second Integer NUmber: ";
- cin >> b;
- sum = a + b;
- product = a * b;
- cout << "The Sum of " << a << "+" << b << "=" << sum << endl;
- cout << "The Product " << a << "*" << b << "=" << product << endl;
- return 0;
- }
- Week 6(a) Solution
- //Program to Welcome Lecturer to Class
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "Welcome to Class Mr. Sokunbi" << endl;
- }
- Week 6(b) Solution
- //Program to print Hello World
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "Hello World" << endl;
- return 0;
- }
- Week 7(Method 1) Solution
- //Program to compute the average of four examination scores
- #include <iostream>
- using namespace std;
- int main()
- {
- int a, b, c, d, sum, avg;
- cout << "Enter four exam scores:" << endl;
- cin >> a >> b >> c >> d;
- sum = a + b + c + d;
- avg = sum / 4;
- cout << "The Average Score is: " << avg << endl;
- return 0;
- }
- Week 7(Method 2) Solution
- //Program to compute the average of four examination scores
- #include <iostream>
- using namespace std;
- int main()
- {
- int i,x, sum = 0; int n = 4;
- int avg;
- for(i=1; i <= n; i++)
- {
- cout << "Enter Exam Score " << i << endl;
- cin >> x;
- sum +=x;
- }
- avg = sum / n;
- cout << "The sum is: " << sum << endl;
- cout << "The Average is: " << avg << endl;
- return 0;
- }
- Week 8(a) Solution
- //Program to compute the distance of the Arch of a circle
- #include <iostream>
- using namespace std;
- int main()
- {
- float radius, value, arch_length;
- cout << "Input the Radius: " << endl;
- cin >> radius;
- cout << "Input the Value: " << endl;
- cin >> value;
- arch_length = 6.28 * radius * (value/360);
- cout << "The Length of Arch is: " << arch_length << endl;
- return 0;
- }
- Week 8(b) Solution
- //Program to Convert Temperature from Celcuis to Farenheit
- #include <iostream>
- using namespace std;
- int main()
- {
- int temp, farenheit;
- cout << "Input Temperature in Celcuis: ";
- cin >> temp;
- farenheit = 1.8 * temp + 32;
- cout << "The Temperature in Farenheit is: " << farenheit << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement