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]
2 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:
Crank2 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
Your principal has hired you to design a drone that can monitor students in the hallways. Before you brainstorm design ideas, yo
torisob [31]
It’s gonna be Answer B because all the other answers just sound silly
8 0
2 years ago
Read 2 more answers
Guyssss......urgent helppp plsss answerrrr
kirill115 [55]

Explanation:

XML

<h2><em><u>pls</u></em><em><u> </u></em><em><u>mark</u></em><em><u> </u></em><em><u>me</u></em><em><u> </u></em><em><u>as</u></em><em><u> </u></em><em><u>brainlist</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>!</u></em><em><u>!</u></em></h2>
7 0
2 years ago
6. Which of the following is malware? (1 point)
marusya05 [52]
Software to damage computers
5 0
3 years ago
Read 2 more answers
Select all that apply.
Valentin [98]

Answer:

1, 3, & 4.

Is the way to do so. Good luck.

6 0
2 years ago
Mobile devices need to work within limited screen space .
zloy xaker [14]
True. Mobile devices need to work within limited screen space. Mobile devices are designed to be portable and designed to be carried around without hassle. Mobile devices are used for personal activities such as talking privately, chatting and many more that is why it is designed to be small.
3 0
3 years ago
Other questions:
  • Landon starts his computer and receives the error message, "Hard drive is not found." In a panic, he calls you because he did no
    14·2 answers
  • Because health and safety are important in all workplaces, not just hazardous ones, what working conditions must ALL employers p
    10·2 answers
  • Properly defined the primary part of a CPU​
    5·1 answer
  • What linux command is used to change file permissions?
    10·1 answer
  • What is the purpose of a mutator?
    8·1 answer
  • Does -8 = -21?<br>[this is NOT a trick question]<br>Yes....?<br>No!​
    12·2 answers
  • To extract detailed and comprehensive responses from your client, use the _____ questioning technique.
    5·2 answers
  • 1. Who was the first lady programmer?​
    14·2 answers
  • Steps for Saving and opening a document.​
    14·1 answer
  • Your friend says, “I can’t ever watch a streaming movie without it pausing for long moments. It makes me crazy!” What might you
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!