Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

java functions

The document outlines a series of programming exercises in Java, focusing on basic functions and control structures. Tasks include calculating averages, sums of odd numbers, determining the greater of two numbers, and checking voting eligibility based on age. Additional challenges involve creating loops, counting user inputs, calculating powers, finding the Greatest Common Divisor, and generating a Fibonacci series.

Uploaded by

Prachi Joshi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

java functions

The document outlines a series of programming exercises in Java, focusing on basic functions and control structures. Tasks include calculating averages, sums of odd numbers, determining the greater of two numbers, and checking voting eligibility based on age. Additional challenges involve creating loops, counting user inputs, calculating powers, finding the Greatest Common Divisor, and generating a Fibonacci series.

Uploaded by

Prachi Joshi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Java - Introduction to Programming

Exercise 1
Questions
1.Enter 3 numbers from the user & make a function to print their average.
2.Write a function to print the sum of all odd numbers from 1 to n.
3.Write a function which takes in 2 numbers and returns the greater of those two.
4.Write a function that takes in the radius as input and returns the circumference of a circle.
5.Write a function that takes in age as input and returns if that person is eligible to vote or not. A person of age > 18 is eligible to
vote.
6.Write an infinite loop using do while condition.
7.Write a program to enter the numbers till the user wants and at the end it should display the count of
positive, negative and zeros entered.
8.Two numbers are entered by the user, x and n. Write a function to find the value of one number
raised to the power of another i.e. xn.
9.Write a function that calculates the Greatest Common Divisor of 2 numbers. (BONUS)
10.Write a program to print Fibonacci series of n terms where n is input by user :
0 1 1 2 3 5 8 13 21 .....
In the Fibonacci series, a number is the sum of the previous 2 numbers that came before it.
(BONUS)

You might also like