1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anni [7]
3 years ago
6

Write a program that accepts cost of food ordered, and it computes Tips (15%), Sales Tax (7%), and Total cost. The program displ

ays food price, sales tax, tip, and total cost of the food. Modify the program to get input from a text file, and create an output file for the same program
Computers and Technology
1 answer:
Mariulka [41]3 years ago
4 0

Answer:

The solution code is written in Python.

<u>First version (user input through terminal)</u>

  1. food_price = float(input("Enter food price: "))
  2. sales_tax = food_price * 0.07
  3. tips = food_price * 0.15  
  4. total_cost = food_price + sales_tax + tips  
  5. print("Food price: $" + str(food_price))
  6. print("Sale tax: $" + str(sales_tax))
  7. print("Tips: $" + str(tips))
  8. print("Total cost: $" + str(total_cost))
  9. print("\n")

<u>Second version (input from text file)</u>

  1. with open("text.txt") as file:
  2.    data = file.readlines()
  3.    for r in data:
  4.        food_price = float(r)
  5.        sales_tax = food_price * 0.07
  6.        tips = food_price * 0.15  
  7.        total_cost = food_price + sales_tax + tips  
  8.        print("Food price: $" + str(food_price))
  9.        print("Sale tax: $" + str(sales_tax))
  10.        print("Tips: $" + str(tips))
  11.        print("Total cost: $" + str(total_cost))
  12.        print("\n")

Explanation:

<u>First version</u>

In the first version of code, we can create all the necessary variables to hold the value of food price, sales tax, tips and total cost (Line 1 -4). Please note we get the food price using the input() function to prompt user to enter the value through terminal (Line 1).

Next display the values using print() function (Line 5 - 8)

<u>Second version</u>

The second version of code is similar to the first version except that we need to change the code to accept input from a text file (Line 1 -2) instead of using the input function.

We presume there might be multiple values in the text file and therefore it is recommended to use readlines() method to get the value line by line from the text file (Line 2) and use for loop to traverse through each row of food price value and calculate the sales tax, tips and total cost (Line 4-7).

You might be interested in
Linda subscribes to a cloud service. The service provider hosts the cloud infrastructure and delivers computing resources over t
siniylev [52]

Answer

Public cloud

Explanation

A cloud service is any service that is made available to users who are on demand via internet from the cloud computing service providers.  These service providers have servers in their company premises where they offer the services from.

A public cloud is a type of computing in which a service provider makes resources available to the public via the internet. The service provider hosts the cloud infrastructure and delivers computing resources over the Internet Resources vary by provider but may include storage capabilities, applications or virtual machines.


3 0
4 years ago
Describe how communication strengthens relationship at work and, as a result, increases your productivity
olganol [36]

Answer:

because it helps them understand their contributions and obligations towards the organisation.

Explanation:

In an organizational setup, the need for healthy and effective communication among employees and employers is a crucial element for the overall success of the organisation. Healthy and effective communication helps in the productivity of the employees because it helps them understand their contributions and obligations towards the organisation.

Good communication improves the employees' morality and sincerity as it helps them feel responsible and as an important member of the organisation. Hence, strengthening their relationships and, as a result, increasing their productivity and efficiency.

7 0
3 years ago
To delete a database object, right-click the object in the Navigation Pane and then click ____ on the shortcut menu.
Reil [10]
Click DELETE on the Shortcut Menu. Be sure that the object you are deleting is closed before because it will not let you delete.
3 0
4 years ago
B. Some of Company X's new practices and systems are unethical. Business ethics is a set of codes
Artemon [7]

Answer:

They are changing schedules without proper notice, cutting workers without proper notice and falsely advertising.

Explanation:

8 0
3 years ago
I figured out the secret message in Dad feels good, I can connect the dots
kati45 [8]

Answer:

Nope you figured it out

Explanation:

3 0
3 years ago
Other questions:
  • You are going to be installing a videoconferencing system. One of the requirements of the system is that only workstations that
    10·1 answer
  • Liz's meeting is scheduled to end at 9:30. It is 9:20 and team
    9·1 answer
  • Replmon is the first tool you should use when troubleshooting Active Directory replication issues. State True or False.
    12·1 answer
  • Jackson is teaching a class the concept of the binary number system. Which term will he use to refer to the leftmost bit of a bi
    7·1 answer
  • Why do most laptops have LCD rather than OLED displays, which are found on mobile devices?
    9·1 answer
  • The invention of the transistor was important to the development of computers because
    14·1 answer
  • Your it department enforces the use of 128-bit encryption on all company transmissions. your department also protects the compan
    13·1 answer
  • What does IDLE stand for
    11·2 answers
  • The analogy of a computer system is often used to illustrate the different parts of memory. The keyboard is where we encode new
    8·1 answer
  • What is the Cycle of Dependency?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!