Approximate the volume of cheese in a rectangular hunk

Assignment Help JAVA Programming
Reference no: EM13165847

You will create a program that will approximate the volume of cheese in a rectangular hunk of Swiss cheese. For this approximation you will assume that the holes in the Swiss cheese are of two types: spherical bubbles (all of the same size) or cylinders (also of the same size).

Your program should include 6 functions in addition to your main function:

  • A void function that will *robustly confirm that the dimension entered is greater than zero. This function should accept 2 arguments: the dimension and what it is. You will call this function 6 times (to check: height of cheese, length of cheese, width of cheese, radius of spheres, radius of cylinders, height of cylinders).
  • A void function that will *robustly confirm that the number entered for holes is greater than zero. This function should accept 2 arguments: the number of holes and what that number corresponds to: spherical bubbles or surface cylinders. You will call this function 2 times.
  • A value-returning function that will accept the radius of a sphere, and then calculate and return the volume of that sphere (vol = 4/3pr3).
  • A value-returning function that will accept the radius and height of a cylinder, and then calculate and return the volume of that cylinder (vol = pr2h).
  • A value-returning function that will accept the height, length, and width of a rectangular parallelepiped and then calculate and return the volume of the rectangular parallelepiped   (vol = hlw).
  • A value-returning function that will accept 8 parameters: (1)width, (2)length, and (3)height of the rectangular hunk of cheese; the (4)number of spherical bubbles and the (5)radius of the bubbles; plus the (6)number of cylindrical holes in contact with a surface and the (7)radius and (8)height of these cylinders. This function will call the functions to calculate the volumes, and then subtract the volumes of spherical bubbles and surface cylinders from the total possible volume of the parallelepiped. The final volume should be returned to main() via the function call. If the volume of cheese is negative, you should handle this appropriately in main().

Your main function should ask the user to input the dimensions of the parallelepiped, the number and size of the spherical bubbles, and the number and dimensions of the surface cylinders. For each of these 8 values your main function should call the functions to confirm input is greater than 0. After this confirmation, the function to approximate the volume of cheese should be called. Then main should output the approximate volume of cheese present. DO NOT assume that the total volume of spherical bubbles and surface cylinders will not exceed the volume of the original hunk.

Make sure you use appropriate data types and that your submission follows the assignment guidelines posted on ANGEL. The value of pi should be declared as a global constant of 3.14159.

Note: for the "what it is" portion of the validity-checking functions, you will need to use a variable type that holds multiple characters.

*robustly confirm: if the item in question is invalid, the function will repeatedly check to make sure that valid input is eventually obtained.

 

Reference no: EM13165847

Questions Cloud

Program to compute each semester tuition for each student : write a program to compute each semester the tuition for each student. Studient is taking 12 credit or less, tuition is 675 oer credit if student is taking more than 12 credits the total tuition is 6300.
Your city''s parking violation : Your city's Parking Violation Bureau wants you to write a program to compute fines for parking violations.
What information do you need to be able to retrieve : What information do you need to be able to retrieve every record from a hashed file in ascending key order?
Input function to prompt the user to enter a square : In the script file, use the input function to prompt the user to enter a square 2-dimensional array. Use a loop to check that user's input is a square array and repeatedly ask the user to enter a square array until they enter a square array (you m..
Approximate the volume of cheese in a rectangular hunk : You will create a program that will approximate the volume of cheese in a rectangular hunk of Swiss cheese. For this approximation you will assume that the holes in the Swiss cheese are of two types: spherical bubbles (all of the same size) or cyl..
Each of the conditional jump statements causes a jump to des : Assume for each part of this problem that the EAX register contains 00 00 00 4F and the doubleword referenced by value contains FF FF FF 38.
Java program that reads an input : Create a java program that reads an input of n lines with the first line being the number of people in the contest and the remaining lines a numeric 9 digit code for each person that gets a vote
Write a program in c# that creates a professorrating class : Write a program in C# that creates a ProfessorRating class consisting of professor ID and three ratings. The three ratings are used to evaluate easiness, helpfulness, and clarity.
Class named stock to model a stock : Write a class named Stock to model a stock. The properties and methods of the class are shown in Figure 6.22. The metho changePercent computes the percentage of the change in the current vs. the previous closing price.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Wrappershallow and wrapperdeep

Each class is simply a wrapper class to hold a private array variable. int [] a; The default constructor for each class should initialize â??aâ??. Each class should have a toString() and equals(). Each class should have a setArray method that allows ..

  Topics: user interface, input validation, computer security

Topics: user interface, input validation, computer security, i/o processing, storage & retrievalAssignment: Write a program that will simulate a basic registration/login process for a standard application or website.Menu ItemsCreate a profileAsk the ..

  Write down the java code for the bank

Write down the java code for the bank of Fraud. User is presented with menu which looks something like this: 1. Deposit 2. Withdrawal 3. Check Balance 4. Exit.

  Die class that can hold an integer

Design a die class that can hold an integer from 1 to 6. use the dice class to create a dice game. in this game, the user chooses a number between 2 and 12 inclusive

  Write an interface for a bagadt that implements iterable

Write an interface for a BagADT that implements the Iterable interface. Include javadoc comments that will generate specifications for the BagADT so that someone who wants to implement this interface will know what each method does.

  Write a program that assigns seats on an airplane

Prepare a program that teaches arithmetic to a young child. The program tests subtraction and addition. Write a program that assigns seats on an airplane.

  Write a recursive public method

Write a recursive public method in our BST class that returns a reference to the information in the node containing the smallest value in the tree. The signature of the method is

  Write a recursive method called maxsum

write a recrusive method called maxSum that accepts a list of integers. L, and an integer limit n as parameters and use backtracking to find the maximum sum that can be generated by adding elements of L that do not exceed n.

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Create java program to describe inheritance and polymorphism

Create a Java program based on the geometric shapes example described at the beginning of this lesson using Classes Square, Triangle, Rectangle, and Circ leto help describe inheritance and polymorphism.

  Vehicle in vehicle.java

Create a class called Vehicle in Vehicle.java with instance variables make (such as Ford, GM, Chrysler, Toyota, or Honda), year, and horsepower (200, 300, and 400). Add the necessary constructor and set and get methods.

  Implement the application using a singly linked list

Implement the following application using a singly linked list. This application accepts from console and stores a list of 10 names of your friends in the singly linked list

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd