Problem with a program that prints a discounted product.

So I need to make a program that reads distance and number of days of a person that is buying a ticket. If distance is greater than 1,000 kilometers AND the person stays more than 7 days, the discount is 30% of the ticket. The cost per kilometer is $1300. Print the ticket with discount

This is what I have
EDIT: used variable distance as float because it will be multiplied with 0.3 for the discount... not sure if I'm right on that

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <conio.h>

using namespace std;



int main()
{
    float distance;

    int days;


    cout << "Welcome!" << endl;

    cout<< "Type the distance in km's of your flight: ";
    cin>>distance;


    cout<< "How many days will you stay?: ";
    cin>>days;

    if ((distance>1000) && (days>7))
    {

        cout<<"Your price with discount is:  " << (distance*2*1300)*(0.3);

    }

else {
    cout<<(distance*2*1300);

}


}



tried another way but haven't done it in code...

1
2
3
4
5
6
7
8
9
ask for distance
ask for days

Ticket= (Dist x 2 x $1300)
If (dist>1000) && (days>7)

cout<<Ticket=Ticket * 0.3;
else { cout<<Ticket;
Last edited on
what is the problem?
finished it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <conio.h>

using namespace std;



int main()
{
    long long distance;

    long long days;


    cout << "Welcome!" << endl;

    cout<< "Type the distance in km's of your flight: ";
    cin>>distance;


    cout<< "How many days will you stay?: ";
    cin>>days;

    if ((distance>1000) && (days>7))
    {

        cout<<"El precio en miles de peso es:  " <<((distance*1300)-((distance*1300)*0.3))/1000;

    }

else {
    cout<<(distance*1300);

}


}
Topic archived. No new replies allowed.