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
#include <iostream>
#include <conio.h>
usingnamespace 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;
#include <iostream>
#include <conio.h>
usingnamespace std;
int main()
{
longlong distance;
longlong 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);
}
}