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
Consider the following program segment. ifstream inFile; //Line 1 int x, y; //Line 2 ... //Line3 inFile >> x >> y; /
AnnyKZ [126]

Answer:

inFile.open("progdata.dat");

Explanation:

5 0
2 years ago
Instructions The population of town A is less than the population of town B. However, the population of town A is growing faster
weeeeeb [17]

Answer: The c++ program is given below.

#include <iostream>

using namespace std;

int main() {

float townA, townB, growthA, growthB, populationA, populationB;

    int year=0;    

cout<<"Enter present population of town A : ";

cin >> townA;  

cout<<endl<<"Enter present growth rate of town A : ";

cin >> growthA;

growthA = growthA/100;  

cout<<endl<<"Enter present population of town B : ";

cin >> townB;  

cout<<endl<<"Enter present growth rate of town B : ";

cin >> growthB;

growthB = growthB/100;  

do

{

    populationA = townA + (townA * growthA);

    populationB = townB + (townB * growthB);      

    townA = populationA;

    townB = populationB;      

    year++;      

}while(populationA < populationB);  

cout<<endl<<"After " <<year<< " years, population of town A is "<<populationA << " and population of town B is "<< population<<endl;

return 0;

}

Explanation:

All the variables for population and growth rate are declared with float datatype.

The user inputs the present population of both the towns.

The growth rate entered by the user is the percentage growth.

For example, town A has 10% growth rate as shown in the output image.

The program converts 10% into float as 10/100.

growthA = growthA/100;

growthB = growthB/100;

The above conversion is done to ease the calculations.

The year variable is declared as integer and initialized to 0.

The growth in population is computed in a do-while loop. After each growth is calculated, the year variable is incremented by 1.

The loop continues until population of town A becomes greater than or equal to population of town B as mentioned in the question.

Once the loop discontinues, the final populations of town A and town B and the years needed for this growth is displayed.

The new line is introduced using endl keyword.

The function main has return type int hence, 0 is returned at the end of the program.

6 0
3 years ago
Mitchell doesn’t have a checking account, but needs to pay a bill, what can Mitchell pay with?
aleksandr82 [10.1K]
Cash, possibly credit card.
5 0
3 years ago
Read 2 more answers
EASY QUESTION EASY POINTS!!!!! WILL MARK BRAINLIEST!!!!!
TEA [102]

The program is an illustration of loops and conditional statements

<h3>Loops</h3>

Loops are used to perform repetitive operations.

<h3>Conditional statement</h3>

Conditional statements are used to make decisions

<h3>The python program</h3>

The program in Python, where comments are used to explain each line is as follows.

#The following is repeated 5 times; i.e. the rows

for i in range(5):

   #The following is repeated 5 times; i.e. the columns

   for j in range(5):

       #For rows 2 and 5

       if i == 1 or i== 3:

           #For columns 1 and 5

           if j == 0 or j == 4:

               #This prints *

               print('*',end='')

           #For other columns

           else:

               #This prints an empty space

               print('',end=' ')

       #For other rows

       else:

           #This prints *

           print('*',end='')

   #This prints a new line

   print()

Read more about loops at:

brainly.com/question/19344465

5 0
2 years ago
Desinated for a network connection within a largecity or multiple small citys
frozen [14]

I think it is WAN (Wide Area Network).

6 0
3 years ago
Other questions:
  • "Dean wants a quick way to look up staff members by their Staff ID. In cell Q3, nest the existing VLOOKUP function in an IFERROR
    10·1 answer
  • 1. A video card on a modem motherboard would run best in which type of slot?
    10·1 answer
  • Is frequency measured in henry.
    14·1 answer
  • A top-notch IT company is seeking an experienced leader to direct a team of experts in the development, creation, and modificati
    14·2 answers
  • What types of storage can be used to access your data on another computer?
    6·2 answers
  • Write a class called (d) Teacher that has just a main method. The main method should construct a GradeBook for a class with two
    7·1 answer
  • You are having trouble closing a program. You have tried to hit the Close button, the keyboard shortcut to close the program, an
    6·1 answer
  • A student who used a regression model that included indicator variables was upset when receiving only the following output on th
    10·1 answer
  • A testing lab wishes to test two experimental brans of outdoor pain long each wiil last befor fading . The testing lab makes six
    11·1 answer
  • Write an algorithm to display your name 10 times​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!