-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhotel.js
More file actions
19 lines (18 loc) · 870 Bytes
/
Copy pathhotel.js
File metadata and controls
19 lines (18 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const totalCost = (hotelOne, hotelTwo, mpg, ppg, totalMiles) => {
let roundTrip = totalMiles * 2;
let totalGallons = roundTrip / mpg;
let priceOfGas = totalGallons * ppg;
console.log(
`this trip will require ${Math.round(totalGallons * 100) / 100} gallons of gas which will cost $${Math.round(priceOfGas * 100) / 100}`,
);
let myCost = (hotelOne + hotelTwo) / 2 + priceOfGas;
let herCost = (hotelOne + hotelTwo) / 2;
let grandTotal = hotelOne + hotelTwo + priceOfGas;
console.log(
`the total cost of this trip will be $${Math.round(grandTotal * 100) / 100}. Sarah will pay $${Math.round(herCost * 100) / 100}, Chason will pay $${Math.round(myCost * 100) / 100}`,
);
console.log(
`the cost for just the hotels per person will be $${Math.round(((hotelOne + hotelTwo) / 2) * 100) / 100}`,
);
};
totalCost(214.04, 97.29, 36, 3.71, 307);