Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a VBA subroutine that takes an input cell(input box) and divides that num

ID: 3758454 • Letter: C

Question

Create a VBA subroutine that takes an input cell(input box) and divides that number by 3 over and over until the result is less than 1. At this point , the sub will display the number of divisions by 3 required to get below 1. The sub must have input validation such that the user MUST input a positive number(can be a non integer) If they do not enter a positive number, the sub will tell them that they need to enter a positive number and then will keep asking for a positive number until they do so. I need the sub code that would be used.

Explanation / Answer

package pkgName;

import java.util.Scanner;

public class NoOfDivision {
static int no;
public int noOfDivision(int no){
   int i=0;
   while(no>=1){
       no/=3;
       i++;
   }
   return i;//return total no of division of 3
}
public static void main(String[] ar){
   Scanner sc= new Scanner(System.in);

System.out.println("enter number");
   no=sc.nextInt();
   while(no<=0){
       System.out.println("please enter positive number");
       no=sc.nextInt();
   }
   NoOfDivision division= new NoOfDivision();
  
   System.out.println(division.noOfDivision(no));
}
}