Last active
May 30, 2019 19:14
-
-
Save sannimichaelse/f653eb8a3e720dbf6189c3f06f935470 to your computer and use it in GitHub Desktop.
C++ Practical Class. Week 1 - 10 Solutions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// index.cpp | |
// Algorithms | |
// | |
// Created by Sanni Michael on 30/05/2019. | |
// Copyright © 2019 Sanni Michael. All rights reserved. | |
#include <iostream> | |
using namespace std; | |
// WEEK 1 | |
int main() | |
{ | |
int numberOfMonths; | |
double payRise = 0.25; | |
double sum = 0.0; | |
cout << "Please Enter Number of Month : "; // This should be 7 according to the queation | |
cin >> numberOfMonths; | |
vector<double> monthArray(numberOfMonths); | |
for (int i = 0; i < numberOfMonths; i++) { | |
cout << "Month #" << i + 1 << " "; | |
cin >> monthArray[i]; | |
} | |
//cout<<accumulate(monthArray.begin(),monthArray.end(),0); // This will print out the sum of all salaries in array | |
for (size_t i = 0; i < monthArray.size(); ++i) { | |
sum += monthArray[i] * payRise; | |
//cout << monthArray[i] << endl; // For printing out individual elements in the vector/array | |
} | |
cout << "\nSum of backdated salary for the past seven months after pay rise " << endl; | |
cout << "\nSum : " << sum << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment