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

Write function headers with comments for the tasks described below and what it r

ID: 3940146 • Letter: W

Question

Write function headers with comments for the tasks described below and what it returns.

a. Computing the larger of two integers

b. Computing the smallest of three floating-point numbers

c. Checking whether an integer is a prime number, returning True if it is and
False otherwise

d. Checking whether a string is contained inside another string

e. Computing the balance of an account with a given initial balance, an annual interest rate, and a number of years of earning interest

f. Printing the balance of an account with a given initial balance and an annual interest rate over a given number of years

g. Printing the calendar for a given month and year

h. Computing the day of the week for a given day, month, and year (as a string such as "Monday") i. Generating a random integer between 1 and n

Explanation / Answer

a. Computing the larger of two integers

   int largerInt(int number1, int number2);
   //It computes and returns the integer which is larger between number1 and number2.
  
b. Computing the smallest of three floating-point numbers

   float smallestFloat(float n1, float n2, float n3);
   //It computes and returns the floating-point number which is smallest among n1, n2, and n3.

  
c. Checking whether an integer is a prime number, returning True if it is and
False otherwise

   boolean isPrime(int number);
   //if number is prime, it returns true; false otherwise
  
d. Checking whether a string is contained inside another string

   boolean isSubstring(String s1,String s2);
   //It returns true if s2 is contained inside s1, and false otherwise
  
e. Computing the balance of an account with a given initial balance, an annual interest rate, and a number of years of earning interest
  
   float calcBalance(float initialBalance,float interestRate, int numberOfYears);
   //It computes and returns the account balance based on the initial balance, interest rate and number of years
  
f. Printing the balance of an account with a given initial balance and an annual interest rate over a given number of years

   void calcBalance(float initialBalance,float interestRate, int n);
   //It just prints the account balance based on the initial balance, interest rate and number of years
   //As it doesn't return anything, it's return type is void.
  
g. Printing the calendar for a given month and year

   void printCalendar(int month, int year);
   //It prints the calendar for the given month of the given year.
  
h. Computing the day of the week for a given day, month, and year (as a string such as "Monday")

   String calcDay(int day, int month, int year);
   //It calculates day of the week and returns it in String data type, based on the given day, month and year
   //If it is for C/C++, you may want to use a character array instead of String.
  
i. Generating a random integer between 1 and n

   int generateRandom(int n);
   //generateRandom method generates a random integer number between 1 and n

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote