answer.
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
Svetllana [295]
2 years ago
14

Dairy Farm decided to ship milk in containers in the form of cubes rather than cylinders. Write a program called ws4.cpp that pr

ompts the user to input the radius of the base and the height of a cylindrical container and outputs the side of the cube with the same volume as the cylindrical container.
Computers and Technology
1 answer:
Sonja [21]2 years ago
3 0

Answer:

1. #include <iostream>

2. #include <cmath>

3.  

4. using namespace std;

5.  

6. int main()

7. {

8.     float radius;  

9.     cout << "Type the radius of the base: "; // Type a number

10.     cin >> radius ; // Get user input from the keyboard

11.      

12.     float height;  

13.     cout << "Type the height: "; // Type a number and press enter

14.     cin >> height; // Get user input from the keyboard

15.      

16.     float volumeCylinder = 3.1416 * radius * radius * height;

17.     float cubeSide = std::pow(volumeCylinder, 1/3.);

18.     cout<<"Cube side is: "<< cubeSide;

19.      

20.     return cubeSide;

21. }

Explanation:

  • From line 1 to 5 we include two libraries
  • From line 6 to 7 we declare our main function
  • From line 8 to 11 we ask the user for the radius of the cylinder
  • From line 12 to 15 we ask the user for the height of the cylinder
  • On line 16 we calculate the volume of the cylinder using the formula        V=pi*(r^2)*h
  • On line 17 we calculate the side of the cube with the same volume as the cylindrical container using the formula side=∛(V)
  • From line 18 to 21 we print and return the value of the cube's side  
Download cpp
You might be interested in
Which of the following option is correct about HCatalog?
adell [148]

Answer:

Option (3) is the correct answer of this question.

Explanation:

  • HCatalog makes available Hive metadata to users of other Hadoop applications, such as Pig, MapReduce and Hive. it offers interfaces for MapReduce and Pig so that users can read data from and write data to the Hive warehouse.
  • This means users don't have to care about where or in what format their data is stored. So we know this way that Hcatalog makes sure our data is secure.
  • Others option does not belong to Hcatalog so these options are incorrect .

8 0
2 years ago
Adele’s mother owns a Daycare and she wants to learn all about this business, to help her mom and own it one day. Which CTSO sho
Gennadij [26K]

Answer:

She should join the Future Business Leaders of America–Phi Beta Lambda

Explanation:

CTSOs are Career and technical student organizations. These organizations are vocational and extracurricular groups based primarily in high schools, colleges and career technological centres, for students in Career and Technical Education. They are important parts of the high school and college programs.

The Future Business Leaders of America–Phi Beta Lambda prepares students to become community-minded business leaders. It provides opportunities to learn career skills and gain leadership experience.

Therefore Adele should pick this CTSO

7 0
2 years ago
Modify the TimeSpan class from Chapter 8 to include a compareTo method that compares time spans by their length. A time span tha
My name is Ann [436]

Answer:

Check the explanation

Explanation:

Here is the modified code for

TimeSpan.java and TimeSpanClient.java.

// TimeSpan.java

//implemented Comparable interface, which has the compareTo method

//and can be used to sort a list or array of TimeSpan objects without

//using a Comparator

public class TimeSpan implements Comparable<TimeSpan> {

   private int totalMinutes;

   // Constructs a time span with the given interval.

   // pre: hours >= 0 && minutes >= 0

   public TimeSpan(int hours, int minutes) {

        totalMinutes = 0;

        add(hours, minutes);

   }

   // Adds the given interval to this time span.

   // pre: hours >= 0 && minutes >= 0

   public void add(int hours, int minutes) {

        totalMinutes += 60 * hours + minutes;

   }

   // Returns a String for this time span such as "6h15m".

   public String toString() {

        return (totalMinutes / 60) + "h" + (totalMinutes % 60) + "m";

   }

   // method to compare this time span with other

   // returns a negative value if this time span is shorter than other

   // returns 0 if both have same duration

   // returns a positive value if this time span is longer than other

   public int compareTo(TimeSpan other) {

        if (this.totalMinutes < other.totalMinutes) {

            return -1; // this < other

        } else if (this.totalMinutes > other.totalMinutes) {

            return 1; // this > other

        } else {

            return 0; // this = other

        }

   }

}

// TimeSpanClient.java

public class TimeSpanClient {

   public static void main(String[] args) {

        int h1 = 13, m1 = 30;

        TimeSpan t1 = new TimeSpan(h1, m1);

        System.out.println("New object t1: " + t1);

        h1 = 3;

        m1 = 40;

        System.out.println("Adding " + h1 + " hours, " + m1 + " minutes to t1");

        t1.add(h1, m1);

        System.out.println("New t1 state: " + t1);

        // creating another TimeSpan object, testing compareTo method using the

        // two objects

        TimeSpan t2 = new TimeSpan(10, 20);

        System.out.println("New object t2: " + t2);

        System.out.println("t1.compareTo(t2): " + t1.compareTo(t2));

        System.out.println("t2.compareTo(t1): " + t2.compareTo(t1));

        System.out.println("t1.compareTo(t1): " + t1.compareTo(t1));

   }

}

/*OUTPUT*/

New object t1: 13h30m

Adding 3 hours, 40 minutes to t1

New t1 state: 17h10m

New object t2: 10h20m

t1.compareTo(t2): 1

t2.compareTo(t1): -1

t1.compareTo(t1): 0

4 0
2 years ago
Which of the following best describes open-source web browsers?
podryga [215]
Hello, Good Works mate!

Answer: A) <span>Open-source web browsers allow non-paid access and distribution.

Kind Regards.</span>
4 0
2 years ago
Read 2 more answers
When Russ opened a website on his browser, he saw an error that the site was not compatible with the browser version he was runn
Umnica [9.8K]

Answer:

Patch finders.

Explanation:

Once Russ accessed a webpage on his computer, he had seen an issue that the page was not associated with the browser variant on which he was executing it, although it was important to use patch finders tool to fix the following problems because patch finder is only the software that can resolve the following issues.

3 0
2 years ago
Other questions:
  • Information gets from sensory memory to short-term memory through the process of _________.
    13·1 answer
  • What is the area of a parallelogram whose vertices are A(−1, 12) , B(13, 12) , C(2, −5) , and D(−12, −5) ? Enter your answer in
    9·2 answers
  • How many frequencies does a full-duplex qam-64 modem use?
    8·2 answers
  • You are given an array x of string elements along with an int variable n that contains the number of elements in the array. You
    11·1 answer
  • True or False: A class that implements an interface may only implement a few of that interface's method declarations
    13·1 answer
  • Assume that we would like to expand the MIPS register file to 128 registers and expand the instruction set to contain four times
    14·1 answer
  • You are the IT security administrator for a small corporate network. Samuel Garcia (sgarcia) has been away on vacation and has f
    9·1 answer
  • 15. It is the process of capturing data or translating information to recording format
    12·1 answer
  • When adopting and implementing a Software as a Service (SaaS) platform such as Salesforce for your business, which responsibilit
    7·1 answer
  • I have a variable and set it equal to 5. 1 then send it as an argument to a function that adds 5 to the variable passed in. Outs
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!