0% found this document useful (0 votes)
23 views

Assignment Java

Java assignment examples

Uploaded by

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

Assignment Java

Java assignment examples

Uploaded by

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

ASSIGNMENT

Subject: Object-Oriented Programming ( JAVA)

THEORY PART

Q.1: Why is Java called a portable and robust programming language?


Q.2: What are the differences between JDK, JRE, and JVM?
Q.3: What is the latest version of JDK, and which version is considered the long-term version?
Q.4: When Java program source code is compiled, what code does it generate?
Q.5: What are the differences between the String, StringBuilder, and StringBuffer classes?
Q.6: What is the difference between the next() and nextLine() methods of the String class?
Q.7: What is the signature/profile of a method? What are the compulsory keywords/components
in the main method's signature?
Q.8: Discuss the basic structure of a Java program.
Q.9: What is the difference between a compiler and an interpreter, and which one does Java use?
Q.10: What are control flow structures? List and discuss them.
Q.11: What is type casting? Differentiate between implicit and explicit type casting.
Q.12: What is an array, and what does the length property of an array return?
Q.13: What are the different editions of Java? List and explain each one.

IMPLEMENTATION PART

Read all instructions, requirements, grading criteria and submission details carefully.

1. Basic Calculator

Objective: The objective of this program is to create a basic calculator in Java. The program should
be able to perform arithmetic operations such as addition, subtraction, multiplication, and
division.

Requirements:

• Your program should have a well-structured Java code with appropriate comments. It
should include a Main class with a main method as the entry point of the program.

• Use the Scanner class to take user input in the form of an expression, for example, '5 +
10', which consists of two numbers and the desired arithmetic operation (addition,
subtraction, multiplication, or division).
• Implement control flow structures like conditional statements for performing the selected
operation).

• Handle any necessary type casting when performing operations or displaying results.
Ensure data integrity and handle errors appropriately.

• Compile and run your Java program. Ensure that it is free of errors and runs successfully.

• Provide clear and concise documentation explaining how to use your calculator program.
Include instructions for inputting numbers and selecting operations.

• Add error handling to your program to handle scenarios like division by zero or invalid
input.

EXAMPLE OUTPUT:

Enter an Expression (e.g., 5 + 10): 10 * 5


Result: 10 * 5 = 50

2. String Manipulation, Arrays and Control Statements

Objective:
The objective of this program is to practice working with strings, arrays, type casting, and control
statements (if and switch) in Java. You will be given a string containing a list of student names and
their scores. Your task is to process this data and perform various operations on it.

Instructions:

Create a Java program that performs the following tasks:

a. Declare and initialize a string variable called "studentData" with the following sample data:

"John:85, Alice:92, Bob:78, Carol:95, David:88, Emma:79, Frank:90"

b. Split the "studentData" string into an array of individual student records. Each record contains
a student's name followed by a colon and their score.

c. Create two arrays:

One to store student names (String array)


One to store student scores (int array)
d. Populate the arrays by extracting data from the split records. Use type casting to convert scores
from strings to integers.

Calculate and display the following statistics for the students:

a. Calculate and display the total number of students.

b. Calculate and display the average score of all students.

c. Find and display the highest score and the name of the student who achieved it.

d. Find and display the lowest score and the name of the student who achieved it.

Test your program with different inputs and ensure it handles the data correctly and provides the
expected output.

NOTE: To convert a number from an input string to an integer, you can use the Integer.parseInt()
method. For example, if s = "5", you can use int a = Integer.parseInt(s);.

Grading Criteria:
Your assignment will be evaluated based on the following criteria:

1. Correctness of the program logic and functionality.


2. Proper use of strings, arrays, type casting, and control statements (if, switch).
3. Proper error handling and input validation.
4. Code clarity, organization, and comments.
5. Adherence to submission guidelines.

. Submission Details:

• You should submit Java programs as a .java file along with a README file, for each
program, containing instructions on how to compile and run the program.
• You should also provide a brief explanation of the design and implementation choices
you made.
• Both the theory and implementation parts should be submitted in a “handwritten
format”, and a soft copy of the implementation part is also required.
• Last Date: On the next class.

You might also like