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
marusya05 [52]
3 years ago
12

Extend to also calculate and output the number of 1 gallon cans needed to paint the wal. Hint: Use a math function to round up t

o the nearest gallon. (Submit for 2 points, so 5 points total)Enter wall height (feet): Enter wall width (feet): Wall area: 1000 square feet Paint needed: 2.86 gallons Cans needed: 3 can(s) Choose a color to paint the wall: Cost of purchasing blue paint: $ {'red': 35, 'blue': 75} Expected output Enter wall height (feet): Enter wall width (feet): Wall area: 1000 square feet Paint needed: 2.86 gallons Cans needed: 3 can(s) Choose a color to paint the wall: Cost of purchasing blue paint: $75

Computers and Technology
1 answer:
Crank3 years ago
5 0

Answer:

Here is the Python program:

import math #import math to use mathematical functions

height = float(input("Enter wall height (feet): ")) #prompts user to enter wall height and store it in float type variable height

width = float(input("Enter wall width (feet): ")) #prompts user to enter wall width and store it in float type variable width

area = height *width #computes wall area

print('Wall area: {} square feet'.format(round(area))) #displays wall area using round method that returns a floating-point number rounded

sqftPerGallon = 350 #sets sqftPerGallon to 350

paintNeeded = area/ sqftPerGallon #computes needed paint

print("Paint needed: {:.2f} gallons".format(paintNeeded)) #displays computed paint needed up to 2 decimal places

cansNeeded = int(math.ceil(paintNeeded)) #computes needed cans rounding the paintNeeded up to nearest integer using math.ceil

print("Cans needed: {} can(s)".format(cansNeeded)) #displays computed cans needed

colorCostDict = {'red': 35, 'blue': 25, 'green': 23} #creates a dictionary of colors with colors as key and cost as values

color = input("Choose a color to paint the wall: ") #prompts user to enter a color

if color in colorCostDict: #if the chosen color is present in the dictionary

    colorCost = colorCostDict.get(color) #then get the color cost from dictionary and stores it into colorCost using get method that returns the value(cost) of the item with the specified key(color)

    cost = cansNeeded * colorCost #computes the cost of purchasing paint of specified color per cansNeeded

  print("Cost of purchasing {} paint: ${}".format(color,colorCostDict[color])) #displays the real cost of the chosen color paint

print("Cost of purchasing {} paint per {} gallon can(s): ${}".format(color,cansNeeded, cost)) #displays the cost of chosen color paint per cans needed.

Explanation:

The program first prompts the user to enter height and width. Lets say user enter 20 as height and 50 as width so the program becomes:

Wall area computed as:

area = height *width

area = 20 * 50

area = 1000

Hence the output of this part is:

Wall area: 1000 square feet                                                                                                                     Next program computes paint needed as:

paintNeeded = area/ sqftPerGallon

Since sqftPerGallon = 350 and area= 1000

paintNeeded = 1000 / 350

paintNeeded = 2.86

Hence the output of this part is:

Paint needed: 2.86 gallons

Next program computes cans needed as:      

cansNeeded = int(math.ceil(paintNeeded))

This rounds the computed value of paintNeeded i.e. 2.86 up to nearest integer using math.ceil so,

cansNeeded = 3                                                                  

Hence the output of this part is:

Cans needed: 3 can(s)                                                                                                                            Next program prompts user to choose a color to paint the wall

Lets say user chooses 'blue'

So the program get the cost corresponding to blue color and multiplies this cost to cans needed to compute the cost of purchasing blue paint per gallon cans. So

cost = cansNeeded * colorCost

cost = 3 * 25

cost = 75

So the output of this part is:

Cost of purchasing blue paint per 3 gallon can(s): $75                                                                                        The screenshot of the program along with its output is attached.

You might be interested in
The purpose of a capacitor unit in a vacuum cleaner is to
krek1111 [17]
I'm currently on this section, so I'll provide you with some help. In the appliance study guide on page 64 it states. "A capacitor may be used in a circuit to help remove radio frequency interference."

So the answer in-fact should be A.


8 0
3 years ago
Disadvantages of computer. ​
SVEN [57.7K]

Answer:You cant carry it around like a phone

Explanation:

7 0
3 years ago
- A blacksmith is shoeing a miser's horse. The blacksmith charges ten dollars for his work. The miser refuses to pay. "Very well
34kurt

Answer:

1+ 2^31= 2,146,483,649 pennies.

in Dollars- $21,464,836.49

edit for total=

42, 929,672. 97

Explanation:

,

8 0
3 years ago
Which technology has the potential to be misused to make atomic bombs? A. computer technology B. nuclear technology C. medical t
Tcecarenko [31]

Answer:

B) Nuclear Technology

Explanation:

Nuclear technology involves atomic nuclei reactions which are used to generate energy. The product of nuclear reactions has huge advantages in Medicine, Agriculture, power generation, Water Desalination etc. However This technology can be misused to produce nuclear bombs (atomic bombs) Which are very dangerous weapons of mass destruction.

Since nuclear reactions involve chain (continous) reactions, they effective damage of detonating a nuclear bomb is huge.

4 0
4 years ago
_____ can be either software-based or deployed via hardware, such as a recording "dongle" that is plugged in between a keyboard
Monica [59]
<span>Keyloggers can be either software-based or deployed via hardware, such as a recording "dongle" that is plugged in between a keyboard and a PC.
</span><span>The keylogger is also called keystroke logger or system monitor. This technology used to monitor and record each keystroke typed on a specific computer's keyboard. </span>
6 0
3 years ago
Other questions:
  • Match the software requirements of a server to their purpose
    5·1 answer
  • How do you represent images in binary
    6·2 answers
  • How do you know if your phone has a virus?
    13·1 answer
  • Which location-sharing service offers items for users as a gaming component and also allows them to collectively link their chec
    9·2 answers
  • Suppose we want to select between two prediction models M1 and M2. We have performed 10-fold cross validation on each. The error
    14·1 answer
  • The {blank} view is the working window of a presentation.
    15·2 answers
  • 11 Select the correct answer. Which external element groups items in a design?
    9·1 answer
  • What are tasks performed by pascaline?​
    8·1 answer
  • Write a program that first reads a list of 5 integers from input. Then, read another value from the input, and output all intege
    5·2 answers
  • Each of the flowchart segments in Figure 3-24 is unstructured. Redraw each segment so that it does the same processes under the
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!