0% found this document useful (0 votes)
2 views4 pages

Lab 3 Tasks

The document outlines a series of Java programming tasks focused on loops, arrays, and methods. It includes requirements for programs that perform various mathematical operations, such as calculating sums, finding prime numbers, and generating loan repayment schedules. Additionally, it covers array manipulations and method implementations for checking properties of numbers and eliminating duplicates.

Uploaded by

Samiul Hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Lab 3 Tasks

The document outlines a series of Java programming tasks focused on loops, arrays, and methods. It includes requirements for programs that perform various mathematical operations, such as calculating sums, finding prime numbers, and generating loan repayment schedules. Additionally, it covers array manipulations and method implementations for checking properties of numbers and eliminating duplicates.

Uploaded by

Samiul Hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Lab 3 Tasks

Topic: Loop in Java.

Write a Java program:


1.​ To take a number input and find the sum of the digits.
2.​ To take a number input, find the first and last digit of the number.
3.​ To find the odd numbers between 2-31.
4.​ To find the odd numbers between m-n,where m and n are two integer variables for which you
have to take input from the console.
5.​ To find the multiplication table of n,where n is an integer variable for which you have to take
input from the console.
6.​ To find the factorial value of any number entered through the keyboard.
7.​ that prompts the user to input an integer and then outputs the number with the digits reversed. For
example, if the input is 12345, the output should be 54321.
8.​ To find if a number is palindrome or not.
Sample input:​ ​ output:
1234​ ​ ​ not palindrome
121​ ​ ​ palindrome
111​ ​ ​ palindrome
12221​ ​ ​ palindrome
2331​ ​ ​ not palindrome
9.​ To find if a number is prime or not.
10.​ To find the prime numbers between 6-30.
11.​ Find the following formation with an input taken from the console
n=4
1234
123
12
1
12.​ Find the following formation with an input taken from the console
n=4
0
10
010
1010
13.​ Find the following formation with an input taken from the console
n=4
0101
010
10
1
14.​ Find the following formation with an input taken from the console
n=4
1111
2222
3333
4444

15.​

The monthly installment for a specific loan covers both the principal and the interest. The
monthly interest is calculated by taking the monthly interest rate and multiplying it by the
balance (the outstanding principal). The principal amount paid for the month is thus the
monthly payment minus the monthly interest. Create a program that allows the user to
input the loan amount, specify the number of years, and interest rate, then present the loan
repayment schedule for the loan. Here is a sample run:

Sample input:
Loan Amount: 10000
Number of Years: 1
Annual Interest Rate: 7

Sample output:
Monthly Payment: 865.26
Total Payment: 10383.21

Payment# Interest Principal Balance

1 58.33 806.93 9193.07

2 53.62 811.64 8381.43

……………….. ………………… ………………… ………………

11 10.0 855.26 860.27

12 5.01 860.25 0.01

For the formula to compute monthly payment, (loan Amount * monthlyInterestRate)/(1- 1


/ (1 + monthlyInterestRate)numberOfYears*12)

16.​ Write a Java program that lets the user enter the loan amount and loan period in number
of years. Then displays the monthly and total payments for each annual interest rate
starting from 5% to 8%, with an increment of 1/8%. Here is a sample run:
Sample input:
Loan Amount: 10000
Number of Years: 5
Sample output:
Interest Rate Monthly Payment Total Payment
5.000% 188.71 11322.74
5.125% 189.29 11357.13
5.250% 189.86 11391.59
………… ………. …………
7.875% 202.17 12129.97
8.000% 202.76 12165.84

For the formula to compute monthly payment, (loan Amount * monthlyInterestRate)/(1- 1 / (1 +


monthlyInterestRate)numberOfYears*12)

Topic: Arrays in Java

Write a Java program


1.​ Find the sum of numbers in an array.
2.​ Copy one array values to the other
3.​ Find the even numbers in an array.
4.​ Find the sum of odd numbers in an array
5.​ Find the odd and even numbers in an array and save them in two different arrays.

Topic: Methods in Java.

Write a Java program


1.​ to check whether a number is even or odd using a method.
2.​ to find the power of any number using a method.
3.​ to check whether a number is palindrome or not using method
4.​ to find the multiplication and summation of two matrices using 2 different methods.(sizes of
matrices and inputs into the matrices from console)
5.​ to find the sum of numbers in a 2D array using a method. (Array should be passed from main
method)
6.​ Write a method that returns a new array by eliminating the duplicate values in the array
using the following method header:

public static int[] eliminateDuplicates(int[] list)

Write a test program that reads in n (an integer variable) integers, invokes the method,
and displays the result. Here is the sample run of the program:
Enter number of integers n=10
Enter 10 numbers: 1 2 3 2 1 6 3 4 5 2
The distinct numbers are: 1 2 3 6 4 5
7.​ Write a method that takes an array of integers input. And returns a random number
between 1 and 54, excluding the numbers passed in the argument. The method header is
specified as follows:
public static int getRandom(int... numbers)

You might also like