domingo, 27 de abril de 2014

work-study helpful program

As a student who is in the work-study program of the university, I constantly have to compute my  remaining hours of work, the salary, time to complete the hours and  divide  my study time with the work time.
I made a personal program that computes the remaining hours, total salary, days left for work and hours per day to complete the assigned hours in the semester. It could be very useful for those who are in the work-study program




#include<iostream>
#include<stdlib.h>
#include<cmath>
using namespace std;
int main(){
double assigned_hours, hours_worked, spare_hours;
double total_salary_assigned,spare_salary, div_hours;
const double minimum_wage=7.25;
int days_left;
char opt;
do{
cout << "This program helps you to organize the college's work-study program of a student\n";
cout << "with a minimum wage of $7.25 per hour\n\n";
cout << "Enter the hours assigned for work\n";
cin >> assigned_hours;
if(assigned_hours <= 0){
cout << "Not a valid input\n";
system("pause");
exit(1);
}
cout << "Now enter the hours that you have worked\n";
cin >> hours_worked;
if(hours_worked > assigned_hours){
cout << "You have completed all the hours\n";
system("pause");
exit(1);
}
else if(hours_worked < 0){
cout << "Not a valid input\n";
system("pause");
exit(1);
}
total_salary_assigned= minimum_wage*assigned_hours;
spare_hours = assigned_hours-hours_worked;
spare_salary = spare_hours*minimum_wage;
cout<< "How many days you got to finish the hours?\n";
cin >> days_left;
if(days_left <= 0){
cout << "You have no days left to complete the remainig hours\n";
system("pause");
exit(1);
}

div_hours = floor(spare_hours/days_left);
cout<< "Your total salary assigned is: $" << total_salary_assigned << endl;
cout << "You have " << spare_hours << " hours to work in " <<days_left << " days\n";
cout << "A total of $" << spare_salary << " is what remains of the inicial salary assigned\n";
cout << "You can work a minimum of "<< div_hours << " hour(s) a day to complete the remaning hours\n";
cout << "Do you want to calculate another? press 'y' if yes else press any key\n";
cin >> opt;
}while(opt == 'y' || opt == 'Y');

return 0;


}