• A void function that will robustly confirm that the value entered for the numb
ID: 3682843 • Letter: #
Question
• A void function that will robustly confirm that the value entered for the number of spherical bubbles or cylindrical pores is greater than or equal zero. This function should accept two parameters: the value and what the value corresponds to i.e. number of spherical bubbles or number of surface cylinders. This function should contain a single loop and no selection structures. If the value is incorrect, tell the user should be told what value (number of spherical bubbles or number of cylindrical pores) is incorrect and prompt the user to re-enter the number. (You may assume that the number will be a whole number). For example you error message should be something like
“The number of spherical bubbles must be greater than or equal to 0. Please re-enter the number of spherical bubbles.”
Explanation / Answer
public void sphericalBubblesOrCylindricalPores(int val,int noOfSbOrSc){
if(noOfSbOrSc<0){
System.out.println("The number of spherical bubbles must be greater than or equal to 0. Please re-enter the number of spherical bubbles");
}else{
System.out.println("Correct value entered!");
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.