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 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...
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?");...
CODE BLOCK E import csv filename = "D:/python/Week8/files/green.csv" with open(filename) as file: data_from_file = csv.reader(file) header_row...
CODE BLOCK E import csv filename = "D:/python/Week8/files/green.csv" with open(filename) as file: data_from_file = csv.reader(file) header_row = next(data_from_file) for index,column_header in enumerate(header_row): print(index,column_header) How many COUMNS (not rows!) will be printed in the above code?
Explain the procedure to generate a cylinder placed on top of a rectangular block using any...
Explain the procedure to generate a cylinder placed on top of a rectangular block using any CAD software.
Using Python In this assignment we will try to add tuples, lists, if statements and strings...
Using Python In this assignment we will try to add tuples, lists, if statements and strings to our program. For example, you can ask for a user for a couple items, their name and age – and depending on their age, print out a predefined list. You could ask for some string input and decide to do something with the output. You could ask for three items, 1) age, 2) are you a male or female and 3) are your...
Problem 2 A block of mass 1 kg is sitting on top of a compressed spring...
Problem 2 A block of mass 1 kg is sitting on top of a compressed spring of spring constant k = 300 N/m and equilibrium length 20 cm. Initially the spring is compressed 10 cm, and the block is held in place by someone pushing down on it with his hand. At t = 0, the hand is removed (this involves no work), the spring expands and the block flies upwards. (a)Draw a free-body diagram for the block while the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT