Sie sind auf Seite 1von 1

Functions Exercise Sheet

Write down the Java code for the following functions:


Create a function that takes two numbers and a basic math operator (+,-,*,/) as a character. In the function,
test the argument mathematical operator and have it return the result of the required mathematical
operation using the two numbers sent.
Write a function to check whether a number is even or odd. The number should be sent as an argument, then
it prints whether it is even or odd.
Write a function to check whether a number is prime, and returns true or false.
Write a function that reads 10 values from user and adds them, then return the summation result.
Repeat the previous function but add an argument that defines how many values you will be reading for the
user to sum.
Write a function that takes an integer and checks if it is a prime number or not, and return the result.

Advanced Programming Course


Dr. Amira Sayed
17/10/2017

Das könnte Ihnen auch gefallen