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

java basic problem statement1

The document outlines a series of Java programming tasks that involve creating various classes and methods, including functionalities for reading floating-point numbers, implementing a counter, and performing mathematical operations. It also includes tasks for creating classes like Dog, Student, Book, Car, and Airplane with specific attributes and methods. Additionally, there is a requirement to compute future investment values based on given inputs.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

java basic problem statement1

The document outlines a series of Java programming tasks that involve creating various classes and methods, including functionalities for reading floating-point numbers, implementing a counter, and performing mathematical operations. It also includes tasks for creating classes like Dog, Student, Book, Car, and Airplane with specific attributes and methods. Additionally, there is a requirement to compute future investment values based on given inputs.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Write a Java program that reads a floating-point number and prints "zero" if the
number is zero. Otherwise, print "positive" or "negative". Add "small" if the absolute
value of the number is less than 1, or "large" if it exceeds 1,000,000.

2. Write a Java program to create a class called "Counter" with a static variable count.
Implement a constructor that increments count every time an object is created. Print
the value of count after creating several objects.

3. Write a Java program to create a class called "MathUtility" with a static method add
that takes two integers and returns their sum. Demonstrate the usage of this static
method in the main method without creating an instance of "MathUtility".

4. Write a Java program to create a class called Dog with instance variables name and
color. Implement a parameterized constructor that takes name and color as
parameters and initializes the instance variables. Print the values of the variables.

5. Write a Java program to create a class called Student with instance variables
studentId, studentName, and grade. Implement a default constructor and a
parameterized constructor that takes all three instance variables. Use constructor
chaining to initialize the variables. Print the values of the variables.

6. Write a Java program to create a class called "Book" with attributes for title, author,
and ISBN, and methods to add and remove books from a collection.

7. Write a Java program to create a class called Car with instance variables make, model,
and year. Implement a parameterized constructor that initializes these variables and
assigns default values if not provided. Print the values of the variables.

8. Write a Java program to create a class called "Book" with instance variables title,
author, and price. Implement a default constructor and two parameterized
constructors:
a. One constructor takes title and author as parameters.
b. The other constructor takes title, author, and price as parameters.
c. Print the values of the variables for each constructor.
9. Write a Java method to compute the future investment value at a given interest rate
for a specified number of years.
Sample data (Monthly compounded) and Output:
Input the investment amount: 1000
Input the rate of interest: 10
Input number of years: 5

Expected Output:
Years FutureValue
1 1104.71
2 1220.39
3 1348.18
4 1489.35
5 1645.31
10.Write a Java program to create a class called "Airplane" with a flight number,
destination, and departure time attributes, and methods to check flight status and
delay.

You might also like