• API
• FAQ
• Tools
• Archive
SHARE
TWEET Untitled a guest May 24th, 2019 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. /*** These are the solutions to the C++ practicals given to us. Feel free to copy and run the code on your systems, but make
2. sure to choose different values as your input at runtime and if possible interchange the variable names.
3.
4. Please if you notice any bugs or errors kindly let me know.
5.
6. NB: Will try to finish up the remaining weeks ASAP.
7.
8. Author: Isaac Adepitan Oluwatoyin
10. ***/
11.
12. Week 1 Solution
13. //Program to calculate 25% payrise of employees for 7 months
14. #include <iostream>
15. using namespace std;
16. int main ()
17. {
18. float asalary, msalary, bdpay, bdpay7;
19. float payrise = 0.25;
20.
21. cout << "Enter your Total Salary for last year" << endl;
22. cin >> asalary;
23.
24. msalary = asalary / 12;
25. cout << "Your monthly salary is: " << msalary << endl;
26.
27. bdpay = msalary * payrise;
28. cout << "Your total 25% increase per month is: " << bdpay << "%" << endl;
29.
30. bdpay7 = 7 * (msalary + bdpay);
31. cout << "Your total 25% increase for 7 months is: " << bdpay7 << "%" << endl;
32.
33. return 0;
34. }
35.
36.
37. Week 2 Solution
38. //Program to Calculate Principal and Interest rate for three years
39. #include <iostream>
40. using namespace std;
41. int main()
42. {
43.     float principal, ainterest, interesty1, interesty2, interesty3;
44.     float arate = 0.1475;
45.
46.     cout << "Enter the principal amount you invested: " << endl;
47.     cin >> principal;
48.
49.     ainterest = principal * arate;
50.     cout << "Your Annual interset is: " << ainterest << endl;
51.
52.     interesty1 = principal + ainterest;
53.     cout << "The Balance for Year 1 is: " << interesty1 << endl;
54.
55.     interesty2 = interesty1 + ainterest;
56.     cout << "The Balance for Year 2 is: " << interesty2 << endl;
57.
58.     interesty3 = interesty2 + ainterest;
59.     cout << "The Balance for Year 3 is: " << interesty3 << endl;
60.
61.     cout << "The Amount Invested was: " << principal << endl;
62.     cout << "The Total Balance for Three Years is: " << interesty3 << endl;
63.
64.     return 0;
65. }
66.
67.
68. Week 5 Solution
69. //Program to find the sum and product of two numbers
70. #include <iostream>
71. using namespace std;
72. int main()
73. {
74.     int a, b, sum, product;
75.     cout << "Enter First Integer NUmber: ";
76.     cin >> a;
77.     cout << "Enter Second Integer NUmber: ";
78.     cin >> b;
79.     sum = a + b;
80.     product = a * b;
81.     cout << "The Sum of " << a << "+" << b << "=" << sum << endl;
82.     cout << "The Product " << a << "*" << b << "=" << product << endl;
83.     return 0;
84. }
85.
86.
87.
88. Week 6(a) Solution
89. //Program to Welcome Lecturer to Class
90. #include <iostream>
91. using namespace std;
92. int main()
93. {
94.     cout << "Welcome to Class Mr. Sokunbi" << endl;
95.
96. }
97.
98.
99. Week 6(b) Solution
100. //Program to print Hello World
101. #include <iostream>
102. using namespace std;
103. int main()
104. {
105.     cout << "Hello World" << endl;
106.     return 0;
107. }
108.
109.
110. Week 7(Method 1) Solution
111. //Program to compute the average of four examination scores
112. #include <iostream>
113. using namespace std;
114. int main()
115. {
116.     int a, b, c, d, sum, avg;
117.     cout << "Enter four exam scores:" << endl;
118.     cin >> a >> b >> c >> d;
119.     sum = a + b + c + d;
120.     avg = sum / 4;
121.     cout << "The Average Score is: " << avg << endl;
122.     return 0;
123. }
124.
125. Week 7(Method 2) Solution
126. //Program to compute the average of four examination scores
127. #include <iostream>
128. using namespace std;
129. int main()
130. {
131.     int i,x, sum = 0; int n = 4;
132.     int  avg;
133.
134.     for(i=1; i <= n; i++)
135.     {
136.         cout << "Enter Exam Score " << i << endl;
137.         cin >> x;
138.         sum +=x;
139.     }
140.     avg = sum / n;
141.     cout << "The sum is: " << sum << endl;
142.     cout << "The Average is: " << avg << endl;
143.     return 0;
144.
145. }
146.
147.
148. Week 8(a) Solution
149. //Program to compute the distance of the Arch of a circle
150. #include <iostream>
151. using namespace std;
152. int main()
153. {
154.     float radius, value, arch_length;
155.     cout << "Input the Radius: " << endl;
156.     cin >> radius;
157.     cout << "Input the Value: " << endl;
158.     cin >> value;
159.     arch_length = 6.28 * radius * (value/360);
160.     cout << "The Length of Arch is: " << arch_length << endl;
161.     return 0;
162. }
163.
164. Week 8(b) Solution
165. //Program to Convert Temperature from Celcuis to Farenheit
166. #include <iostream>
167. using namespace std;
168. int main()
169. {
170.     int temp, farenheit;
171.     cout << "Input Temperature in Celcuis: ";
172.     cin >> temp;
173.     farenheit = 1.8 * temp + 32;
174.     cout << "The Temperature in Farenheit is: " << farenheit << endl;
175.     return 0;
176. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top