Sort 2493 Discussions, By:
Please Login in order to post a comment
To make it work student has to delete everything that is not hardcoded and use arguments "mealCost", "tipPercent" and "taxPercent" in the calculation (do NOT try to readLine() or something, all the data is already read in the hardcoded part).
# Complete the solve function below.
def solve(meal_cost, tip_percent, tax_percent):
if __name__ == '__main__':
meal_cost = float(input())
tip_percent = int(input())
tax_percent = int(input())
tip = (meal_cost * tip_percent) / 100
tax = (meal_cost * tax_percent) / 100
totalCost = int(round(meal_cost + tip + tax))
solve(meal_cost, tip_percent, tax_percent)
I'm having some problem with this. It just keeps showing me wrong answer.
Mind I add that when I switch the default code from C++ to Python 3 it shown me that the f __name__ == '__main__': doesn't have an indent. After I add it, I still get wrong answer.
f __name__ == '__main__':
I was able to finish but I'm curious.
correct and the following wrong even if the second is done separately and stored through a double?
And this is the Solution in c++
cin >> mealCost;
cin >> tipPercent;
cin >> taxPercent;
tipPercent = round(mealCost * tipPercent/100);
taxPercent = round(mealCost * taxPercent/100);
totalCost = mealCost + tipPercent + taxPercent;
cout << "The total meal cost is " << totalCost << " dollars.";
You would want to do this in a more effient way but broke down how each one was caculated in C#.
// Get the Tax
double tax = (meal_cost * tax_percent) / 100;
// Get the Tip
double tip = (meal_cost * tip_percent/100);
// Total Cost
double totalCost = meal_cost + tax + tip;
// Round the total cost and output to console
Console.WriteLine("The total meal cost is "
+ Math.Round(totalCost) + " dollars.");