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
mariarad [96]
3 years ago
15

Write a program that prompts the user to enter the area of the flat cardboard. The program then outputs the length and width of

the cardboard and the length of the side of the square to be cut from the corner so that the resulting box is of maximum volume. Calculate your answer to three decimal places. Your program must contain a function that takes as input the length and width of the cardboard and returns the side of the square that should be cut to maximize the volume. The function also returns the maximum volume.
Computers and Technology
1 answer:
lyudmila [28]3 years ago
4 0

Answer:

A program in C++ was written to prompts the user to enter the area of the flat cardboard.

Explanation:

Solution:

The C++ code:

#include <iostream>

#include <iomanip>

#include <cmath>

using namespace std;

double min(double,double);

void max(double,double,double&,double&);

int main()

{double area,length,width=.001,vol,height,maxLen,mWidth,maxHeight,maxVolume=-1;

cout<<setprecision(3)<<fixed<<showpoint;

cout<<"Enter the area of the flat cardboard: ";

cin>>area;

while(width<=area)

{length=area/width;

max(length,width,vol,height);

if(vol>maxVolume)

{maxLen=length;

mWidth=width;

maxHeight=height;

maxVolume=vol;

}

width+=.001;

}

cout<<"dimensions of card to maximize the cardboard box which has a volume "

<<maxVolume<<endl;

cout<<"Length: "<<maxLen<<"\nWidth: "<<maxLen<<endl;

cout<<"dimensions of the cardboard box\n";

cout<<"Length: "<<maxLen-2*maxHeight<<"\nWidth: "

<<mWidth-2*maxHeight<<"\nHeight: "<<maxHeight<<endl;

return 0;

}

void max(double l,double w,double& max, double& maxside)

{double vol,ht;

maxside=min(l,w);

ht=.001;

max=-1;

while(maxside>ht*2)

{vol=(l-ht*2)*(w-ht*2)*ht;

if(vol>max)

{max=vol;

maxside=ht;

}

ht+=.001;

}

}

double min(double l,double w)

{if(l<w)

return l;

return w;

}

Note:  Kindly find the output code below

/*

Output for the code:

Enter the area of the flat cardboard: 23

dimensions of card to maximize the cardboard box which has a volume 0.023

Length: 4.796

Width: 4.796

dimensions of the cardboard box

Length: 4.794

Width: 4.794

Height: 0.001

*/

You might be interested in
Jody should select the
Alex Ar [27]

Answer:

In the View tab, you will find Zoom Option. Set the Zoom level to 100%.

Explanation:

You need to set the Zoom level to 100%, And you can do this, by setting the zoom level to 100%, from the scroll bar. Or you can move to view tab in the main menu, and then in the Ribbon, you need to select the zoom % and set it to 100 percent. You will then be able to see the entire page. And if you want, you can increase the Zoom level to even further, for getting an even more clearer picture.

3 0
3 years ago
In python 3.17 LAB: Convert to dollars
krok68 [10]

To convert the inputs to dollars and cents, we make use of a combination of multiplication and addition.

The program written in Python where comments are used to explain each line is as follows:

<em />

<em>#This gets input for the number of quarters</em>

quarters = int(input("Quarters: "))

<em>#This gets input for the number of dimes</em>

dimes = int(input("Dimes: "))

<em>#This gets input for the number of nickels</em>

nickels= int(input("Nickels: "))

<em>#This gets input for the number of pennies</em>

pennies= int(input("Pennies: "))

<em>#This converts the amount to dollars and cents</em>

dollars = quarters * 0.25 + dimes * 0.10 + nickels * 0.05 + pennies * 0.01

<em>#This prints the amount to 2 decimal places</em>

print("Amount ${:.2f}".format(dollars))

Read more about Python programs at:

brainly.com/question/22841107

7 0
2 years ago
The Internet began when a large company wanted to sell products online
aalyn [17]
No!The internet began in the 1950s when the US government was trying to use connected computers to compete with the Soviet Union's Sputnik. Hope this helps :)
6 0
2 years ago
What doe the &amp; operator do in python programming software
ArbitrLikvidat [17]
Hardware software is the answer
5 0
3 years ago
Types in java are divided into two categories. the primitive types are boolean, byte, char, short, int, long, float and double.
Rudik [331]
Types in java are divided into two categories. the primitive types are boolean, byte, char, short, not, long, float, and double. all other types are REFERENCE types
4 0
2 years ago
Other questions:
  • What does raster graphic mean
    5·1 answer
  • What is the purpose of copyfitting?
    12·1 answer
  • Although highly accurate navigational information from the GPS constellation is exploitable by adversary forces, it is unlikely
    5·1 answer
  • Which branch of science helps avoid or minimize stress-related injuries at workplace?
    12·2 answers
  • Write a function called simulate_several_key_strikes. It should take one argument: an integer specifying the number of key strik
    7·1 answer
  • What are data structures and algorithms? Why are they important to software developer?
    14·1 answer
  • What is the smallest amount of information called?
    13·2 answers
  • 27. If X and Y are int type variables,
    14·1 answer
  • Once the CPU has fetched the data requested, what are the next steps in the process?
    15·1 answer
  • HELPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP!!!
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!