Write a c++ program to compute Number of visits for salesman per month, where he takes 60 minutes in each visit and 15 minutes to move from visit to other. Then compute the total profit for this salesman if you know that the return profit for each visit is 500 L.E. in the first two weeks of the month, then it increment by 10% in the second half of the month.

Note that salesman works 11 hours / day.

Have you tried to do this yet? Show us what you've written so far, and we can help with specific problems you're having.

What have you done, besides posting your homework assignment?
Show your code to us and pinpoint the errors you have.
We will be more than happy to help.

#include <iostream>
using namespace std;
void main()
{
    int x; 
    int minutes;
    int hour;
    cout<< "how many vist ? ";
    cin>>x;
    minutes = x * 60 + (x - 1) * 10;
        cout << minutes <<endl;
        system("pause");
} 


not completed yet :S
#include <iostream>
using namespace std;
void main()
{
    int x;
    int minutes;
    int cash;
    cout << "how many vist ? ";
    cin >> x;
    minutes = x * 60 + (x - 1) * 15;
    cash = (x * 500) * 14 + ((x * 500) * (16))*(0.10);
    cout << minutes << endl;
    system("pause");
}


not completed yet

You should not be getting any input from the user. You need to figure out how many appointments the sales person can do per day. Once you know that then you know how many visits he can do in 2 weeks. Once you have that then you can multiply the 2 week total by 110% to find out the second 2 week amount. Add those two numbers together and now you have the total profit per month.

Most of programing is problem solving. Solve the problem manually and then translate those steps into code. using psuedocode is another way to help the transition from pen and paper to code.

Comments
extensive advise.
#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    int MinutesVisit = 60;
    int MinutesRoad = 15;
    int HourOfWork = 11;
    int PriceForVisit = 500;

    int DayInMonth = 30;
    int DayNotBonus = 14;
    int BonusProcent = 10;

    int MinutesOfWork = HourOfWork * 60;
    int  Visits = 0;
    do
        {
          MinutesOfWork = MinutesOfWork - MinutesVisit;
          Visits++;
          MinutesOfWork = MinutesOfWork - MinutesRoad;
        } 
    while (MinutesOfWork > MinutesVisit);

    float CashOneDay = Visits * PriceForVisit;
    float TotalSum = CashOneDay * DayNotBonus + CashOneDay*(DayInMonth - DayNotBonus) * (1 +  BonusProcent / 100.0);
    cout << TotalSum;
    return 0;
}

Edited 1 Year Ago by dima.shatorny

And? Is there a problem or you just showing the final code? I do think while (MinutesOfWork > MinutesVisit); should be while (MinutesOfWork >= MinutesVisit);

#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    int MinutesVisit = 60;
    int MinutesRoad = 15;
    int HourOfWork = 11;
    int PriceForVisit = 500;
    int DayInMonth = 30;
    int DayNotBonus = 14;
    int BonusProcent = 10;
    int MinutesOfWork = HourOfWork * 60;
    int  Visits = 0;
    do
        {
          MinutesOfWork = MinutesOfWork - MinutesVisit;
          Visits++;
          MinutesOfWork = MinutesOfWork - MinutesRoad;
        } 
    while (MinutesOfWork >= MinutesVisit);
    float CashOneDay = Visits * PriceForVisit;
    float TotalSum = CashOneDay * DayNotBonus + CashOneDay*(DayInMonth - DayNotBonus) * (1 +  BonusProcent / 100.0);
    cout << TotalSum;
    return 0;
}

void main()

Don't forget it is int main()

#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])

The following header file implementation will only work on windows platforms, if you want better c++ code best to use standard headers or a standard c++ compiler.

#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
    int MinutesVisit = 60;
    int MinutesRoad = 15;
    int HourOfWork = 11;
    int PriceForVisit = 500;
    int DayInMonth = 30;
    int DayNotBonus = 14;
    int BonusProcent = 10;
    int MinutesOfWork = HourOfWork * 60;
    int  Visits = 0;
    do
        {
          MinutesOfWork = MinutesOfWork - MinutesVisit;
          Visits++;
          MinutesOfWork = MinutesOfWork - MinutesRoad;
        } 
    while (MinutesOfWork >= MinutesVisit);
    float CashOneDay = Visits * PriceForVisit;
    float TotalSum = CashOneDay * DayNotBonus + CashOneDay*(DayInMonth - DayNotBonus) * (1 +  BonusProcent / 100.0);
    cout << TotalSum;
    return 0;
}
This question has already been answered. Start a new discussion instead.