(b) Add a function for determining the area of a circle, and add this information to your output for the user.
(c) Are there values for the radius that don't make sense? Disallow this type of input and notify the user of the problem. Since you should be using a loop, the user will be asked to enter their value again.
(d) Build in a way to exit the program.
(b) Write a function max2() that will accept two integer values and returns the larger of the two values.
Turing Solution
(c) Write a function min3() and max3() which work for three integer values.
(d) Use method overloading to modify your methods to be named max() and min(), with different code to handle two or three input integer parameters.
For example, 5! = 5 x 4 x 3 x 2 x 1 = 120
Create a function to implement the factorial operation and write a program to test it.
(b) Enhance your program to disallow invalid values.
(b) Use a random number instead of user input, and let the user specify how many numbers to run. At the end of the program, report the total number of evens and odds.
For example, digit(54321, 2) would return the second digit, which is the integer value '4'
(b) Create a boolean function (true/false) called allDigitsEven() that will accept a positive integer value and return true if each digit is even, and false if any digit is not even. (Hint: You will need to use string functions to accomplish this task).
(c) Use this function to write the program for Exercises - String Operations #6.
(b) Write a program to allow the user to specify a number, and display all of the prime numbers between 1 and the user's number. This program will use your isPrime() function developed in part (a).
- a year that is divisible by 4 (e.g., 1988, 1992, 1996 are all leap years)
- centennial years (divisible by 100) do not follow this rule (e.g., 1800, 1900 are NOT leap years)
- except centennial years divisible by 400, which are leap years (e.g., 2000 is a leap year)
(a) Create a boolean function that will determine if a given year is a leap year by returning true or false for a given year.
The absolute value is a mathematical function for determining the size, or magnitude, of a value. The answer is always a positive number.
For example, the absolute value of 5 is 5. The absolute value of -11.2 is 11.2.
(a) Write a function called absolute() that accepts a real input and gives a real output. Write a simple program to test your function. If your programming language already has an absolute value function, do not use it. The goal here to is write your own version of the function. (Turing Solution)