Question

In: Computer Science

2. Add a title comment block to the top of the new Python file using the...

2. Add a title comment block to the top of the new Python file using the following form # A brief description of the project

3. Ask user - to enter the charge for food

4. Ask user - to enter theTip for server ( remember this is a percentage , the input therefore should be decimal. For example, for a 15% tip, 0.15 should be entered)

5. Ask user - to enter the Tax amount ( this is a percentage too, so for a 6% tax , 0.06 should be entered)

6. Calculate tip and tax

7. Display the following: *Calculated tip *Calculated tax *Display total cost of meal ( food charge + tip+ tax)

8. What is the finished code solution file(s)

Notes: the tip , tax and amount are to be requested from the user, they are NOT hard coded (fixed amounts) Write program Pseudocode ( detail algorithm) and add it as a comment block to the submitted program.

Solutions

Expert Solution

'''

Python version : 2.7

Python program to calculate the total cost of meal

'''

'''

Pseudocode:

1. Input the charge of food, tip percent and tax percent from user

2. Calculate tax = charge*taxPercent

3. Calculate tip = (charge+tax)*tipPercent

4. Calculate total charge = charge+tax+tip

5. Display tip, tax and total charge

'''

# input the charge of food

cost = float(raw_input('Enter the charge for food : '))

# input the tip as percent value

tipPercent = float(raw_input('Enter the tip for the server : '))

# input the tax as percent value

taxPercent = float(raw_input('Enter the tax amount : '))

# calculate the total tax on the food

tax = cost*taxPercent

# calculate total cost as cost + tax

totalCost = cost + tax

# calculate the tip on total amount

tip = totalCost*tipPercent

# add tip to total cost

totalCost += tip

# print the tip, tax and total charge of meal

print('Calculated tip : $%.2f' %(tip))

print('Calculated tax : $%.2f' %(tax))

print('Display total cost of meal : $%.2f' %(totalCost))

#end of program

Code Screenshot:

Output:


Related Solutions

python Create a new file name condition_quiz.py. Add a comment with your name and the date....
python Create a new file name condition_quiz.py. Add a comment with your name and the date. Prompt the user to enter the cost. Convert the input to a float. Prompt the user for a status. Convert the status to an integer Compute the special_fee based on the status. If the status is 0, the special_fee will be 0.03 of the cost. Else if the status is 1, the special_fee will be 0.04 of the cost. Else if the status is...
Create a new file name condition_quiz.py. Add a comment with your name and the date. Prompt...
Create a new file name condition_quiz.py. Add a comment with your name and the date. Prompt the user to enter the cost. Convert the input to a float. Prompt the user for a status. Convert the status to an integer Compute the special_fee based on the status. If the status is 0, the special_fee will be 0.03 of the cost. Else if the status is 1, the special_fee will be 0.04 of the cost. Else if the status is 2,...
​​​​Python Create a new file named compute_cost.py. Write your name and date in a comment. Create...
​​​​Python Create a new file named compute_cost.py. Write your name and date in a comment. Create a variable named base_fee and set the value to 5.5. Prompt the user for the zone. The zones can be an integer value from 1 to any value for the zone. Convert the zone to an integer. Display the zone on the SenseHat with a scroll speed of 0.3, make the text blue, and the background yellow. Scroll "The zone is " and the...
Python Please debug each python block. Do not change the algorithm. You can add statements or...
Python Please debug each python block. Do not change the algorithm. You can add statements or you can modify existing python statements. #2) The below code prints all numbers from 5 to 20. Modify the below while loop to print odd numbers from 5 to 21, # including 21. Correct syntax errors as well. i = 5 while(i<21): print(i) i = i+1
Write a python program: There is a file called file 2. File2 is a txt file...
Write a python program: There is a file called file 2. File2 is a txt file and I have written the contents of file 2 below in the exact format it was in notepad. # This comment does not make sense # It is just to make it harder # The job description starts after this comment, notice that it has 4 lines. # This job description has 700150 hay system points\\ the incumbent will administer the spending of kindergarden...
In IDLE - Python 3, do the following: 1. Create File --> New 2. Enter the...
In IDLE - Python 3, do the following: 1. Create File --> New 2. Enter the code below in the new file (you may omit the comments, I included them for explanation #Python Code Begin x = int(input("Enter a number: ")) y = int(input("Enter another number: ")) print ("Values before", "x:", x, "y:", y) #add code to swap variables here #you may not use Python libraries or built in swap functions #you must use only the operators you have learned...
Submit: One python file __name__ == "__main__" Screenshot of sample output Be sure to: Comment your...
Submit: One python file __name__ == "__main__" Screenshot of sample output Be sure to: Comment your code, classes and functions! Practice practice practice! Use meaningful variables If you do not I will remove points Dog Walker Program Create a program for a Dog Walking company to keep track of its employees, customers, and customer dogs You will need the following classes: Person With the following attributes: name id_number dogs : list of Dog objects With the appropriate setters and getters...
Using Python. A file exists on the disk named students.txt. The file contains several records, and...
Using Python. A file exists on the disk named students.txt. The file contains several records, and each record contains two fields: (1) the student’s name, and (2) the student’s score for the final exam. Write code that deletes the record containing “John Perz”as the student name. This the code i have so far but it's not working: import os def main(): found=False search='John Perz' student_file = open('student.txt','r') temp_file = open('temp_students.txt','w') name=student_file.readline() score='' while name !='': score=student_file.readline() name=name.rstrip('/n') score=score.rstrip('/n') if name...
IN PYTHON File Data --- In file1.txt add the following numbers, each on its own line...
IN PYTHON File Data --- In file1.txt add the following numbers, each on its own line (20, 30, 40, 50, 60). Do not add data to file2.txt. Write a program. Create a new .py file that reads in the data from file1 and adds all together. Then output the sum to file2.txt. Add your name to the first line in file2.txt (see sample output) Sample Output Your Name 200 use a main function.
Modify the following program. Add using Exception handing and polymorphism. try-catch block, Finally block in java...
Modify the following program. Add using Exception handing and polymorphism. try-catch block, Finally block in java * description of class Driver here. *these is the main class where it acts like parent class. Compiler will execute firstly static method. import java.util.Scanner; public class Driver {     public static void main (String[] args){         Scanner stdIn = new Scanner(System.in);         String user;         String computer;         char a = 'y';         do {             System.out.println("What kind of Computer would you like?");...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT