Question

In: Computer Science

COVID -19 changed our lifestyles in so many different ways. Due to safety concerns, suddenly everyone...

COVID -19 changed our lifestyles in so many different ways. Due to safety concerns, suddenly everyone wants to wear face masks. However, as the suppliers fail to keep up with the demand, one option is to use homemade facemasks.

According to the crafting experts, one adult mask requires two 9" x 6" pieces of tight-weave cotton and two 7" pieces of elastic. The elastic only sold in full yards.

Write a program that reads the length (in yards) and width (in inches) of a piece of fabric from the user and displays the following.

  • How many adult masks you can make from this fabric?
  • How many yards of elastic required. (The elastic only sold in full yards.)

For example,

  • 1 yard of 44" wide fabric yields 14 facemasks.
  • You will need 6 yards of elastic.

Notes:

  • 9" = 9 inches
  • 1 yard = 36" (inches)
  • Hints: You can use the int() function or floor-division to round down a floating-point number. You can use math.ceil() function to round up a floating-point number.

Solutions

Expert Solution

Here we need to take length in yards and width in inches

since one mask requires two 9X6 pieces of weaven cotton and two 7 inches pieces of elastic

so inorder to get total no of masks that can be made from the given cotton is

for the given test case

that is 1 yard and 44 inches

(36*44)/(2*9*6)=14.66

but we require maximum so we will take floor and round it to 14

so as we know that a mask require 2 elastic of 7 inches

so 14 masks will require 14*2*7 inches converting it to yard

(14*2*7)/36 and take ceil of it

6 yards of elastic required

Below is the code Attached with Output attached

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int cloth,w;
  cout<<"Enter length in yards\n";
  cin>>cloth;
  int c=cloth;
  cout<<"Enter the width in inches\n";
  cin>>w;
  cloth*=36;//converting to inches
  float z=2*9*6;
  float l=(float)(cloth*w)/z;
  int p=floor(l);
  cout<<c<<" yard cloth will yeild "<<p<<"facemasks"<<"\n";
  int k=p*14;
  float elast=(float)k/36;
  cout<<"You will require "<<ceil(elast)<<"elastic"<<"\n";
  
  

    return 0;
}


Related Solutions

What are the new economic norms due to Covid-19, and how will these affect daily lifestyles...
What are the new economic norms due to Covid-19, and how will these affect daily lifestyles and learning or work practices?
Due to the COVID-19 epidemy, with so many working and studying remotely, the Internet’s capacity is...
Due to the COVID-19 epidemy, with so many working and studying remotely, the Internet’s capacity is under considerable strain. Unfortunately, this has put a huge load on Internet Service Providers (ISPs) and we can only expect the situation to worsen with time. Propose a fix/solution to the TCP/IP protocol suite to help the Internet overcome its capacity bottleneck/s. For example, you may focus on fixing a specific problem at a particular layer of the protocol stack or improving a known...
How has your attitude(s) and behavior(s) toward sexual practices changed due to COVID-19? In what ways?...
How has your attitude(s) and behavior(s) toward sexual practices changed due to COVID-19? In what ways? What kind of impact (cultural or otherwise) do you think COVID-19 will have on the world in terms of intimacy, and physical contact in the long-term? Need 400 words minimum.
Dieting is common in our society and everyone wants a piece of the action. So many...
Dieting is common in our society and everyone wants a piece of the action. So many diets are available to choose from if someone wants to change their health; e.g., lose weight. Often times, diets are promoted with claims of great success. Choose a particular diet and analyze it in terms of scientific evidence, or lack thereof. Then, design a controlled experiment to test a hypothesis based on this diet. The experiment must include multiple individuals within a control and...
How has Covid-19 impacted Zoom's staffing due to Covid-19 social distancing rules and so on?
How has Covid-19 impacted Zoom's staffing due to Covid-19 social distancing rules and so on?
(i) Due to COVID-19, our company allows our staff to choose between working in the office...
(i) Due to COVID-19, our company allows our staff to choose between working in the office or from home. Based on your choice, how could you ensure that you will be able to deal with our customers effectively and efficiently?
There is much discussion about how the COVID-19 pandemic has changed the world. In what ways...
There is much discussion about how the COVID-19 pandemic has changed the world. In what ways do you think the pandemic has impacted marketing in the short and longer terms? What opportunities and what threats do you think marketers are faced with due to the impact of the pandemic?
Que: Technology has changed our lives in many ways. Think of a development in technology, such...
Que: Technology has changed our lives in many ways. Think of a development in technology, such as the widespread use of cellular phones or the availability of the Internet. Write an essay in which you explain the causes and effects of this development on our lives. (Answered need to be in soft copy only)
The recent outbreak of novel coronavirus (COVID-19) has changed the world as we know it. Many...
The recent outbreak of novel coronavirus (COVID-19) has changed the world as we know it. Many new challenges are faced. The outbreak is moving quickly, and most countries are trying to respond quickly to contain the impact. However, the spread of the virus may continue throughout the upcoming years and impact the operations of many industries for years to come. Accordingly, change has become an urgent need and no longer considered as a luxury or a choice. Taking the health...
Covid-19 has disrupted many businesses and changed the business environment. •As a CRM consultant, was asked...
Covid-19 has disrupted many businesses and changed the business environment. •As a CRM consultant, was asked by a local business magazine to write an article about how organizations can use CRM to restore business. •Propose guidelines about how companies should do and what they should avoid doing. And, explain reasons for such guidelines.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT