-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarning.cpp
More file actions
25 lines (21 loc) · 881 Bytes
/
warning.cpp
File metadata and controls
25 lines (21 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//This code generates warnings with relevant data if applicable
#include "head.hpp"
#include <iostream>
double calc_save(double bud,double exp,int day_pass) //day_pass = no of days passed
{
double avg_save=exp/day_pass;
double predict_save = bud-(avg_save*30.5); //savings prediction logic
return predict_save;
}
double warning(double bud,double exp,int day_pass){
double predict_save=calc_save(bud,exp,day_pass);
std::cout<<"____________________________"<<std::endl;
if(predict_save<0.0){
std::cout<<"Warning : You are overspending ! Projected to overshoot the budget by "<<abs(predict_save)<<" this month."<<std::endl;
}
else{
std::cout<<"Well done ! You are on the way to save "<<predict_save<<" by the end of the month.\n";
}
std::cout<<"____________________________"<<std::endl;
return predict_save;
}