Java program for calculating math problems


Question 1: Write a Java program which computes and prints the simple interest by using the formula:

Simple Interest = PNR / 100

Input values P, N, R should be accepted as command line input as shown below.

Example:  java SimpleInterest  5  10  15

Question 2: Write a program to calculate sum of digits of a given number.

Question 3: The numbers in the given sequence are termed as the Fibonacci numbers.

0, 1, 1, 2, 3, 5, 8, 13,…………..

Write a program by using do…..while loop to compute and print the first m Fibonacci numbers.

Question 4: Write a program which converts a decimal number to Roman number. Decimal Number is accepted as command line input at the time of execution.

Question 5: Write a program which prints prime numbers between 1 to n. Number n must be accepted as command line input.

Question 6: Write a program to print the given output by using the for loop.

1
2  2
3  3   3
4  4   4   4
5  5   5   5   5

Question 7: Write a Java program which accepts the radius of a circle and displays the options as follows:

a) Find out the diameter of a circle. (2* radius)
b) Find out the area of circle. (Π * radius * radius)
c) Find out the circumference of a circle. (2 * Π * radius)
d) Exit.

Use case statement to implement each option and display the corresponding output.

Question 8: Define a class called fruit with the given attributes:

a) Name of the fruit.
b) Single fruit or bunch fruit.
c) Price.

Define an appropriate constructor and displayFruit() method which displays values of all the attributes. Write a program which creates 2 objects of fruit class and display their attributes.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Java program for calculating math problems
Reference No:- TGS03127

Expected delivery within 24 Hours