Lesson 2.8: Module Assignment
Introduction
Congratulations! You have completed Module 2: Variables, Data Types, Operators, and User Input.
This assignment is designed to test your understanding of all the concepts covered in this module. Complete each question without copying code from previous lessons. If you get stuck, review the related lesson before trying again.
Assignment Objectives
After completing this assignment, you should be able to:
-
Declare and initialize variables.
-
Use appropriate data types.
-
Perform arithmetic operations.
-
Accept user input using the Scanner class.
-
Apply type casting where required.
-
Write clean and well-formatted Java programs.
Instructions
-
Create a separate Java file for each program.
-
Use meaningful variable names.
-
Follow proper indentation.
-
Test each program before submission.
-
Save all programs in a folder named Module2_Assignment.
Question 1: Student Information
Write a Java program to accept the following details from the user:
-
Student Name
-
Roll Number
-
Age
-
Department
-
Semester
Display the details in a neat format.
Question 2: Arithmetic Calculator
Write a Java program that accepts two numbers and displays:
-
Addition
-
Subtraction
-
Multiplication
-
Division
-
Modulus
Question 3: Area Calculator
Write a Java program to calculate:
-
Area of a Rectangle
-
Area of a Circle
Take all required values from the user.
Question 4: Student Marks
Accept marks of five subjects.
Display:
-
Total Marks
-
Average Marks
Question 5: Temperature Converter
Accept temperature in Celsius and convert it to Fahrenheit.
Formula:
F = (C × 9 / 5) + 32
Question 6: Employee Salary
Accept:
-
Employee Name
-
Employee ID
-
Basic Salary
Calculate:
-
HRA = 20% of Basic Salary
-
DA = 10% of Basic Salary
-
Gross Salary = Basic Salary + HRA + DA
Display all details.
Question 7: Swap Two Numbers
Create two separate programs:
Program A
Swap two numbers using a third variable.
Program B
Swap two numbers without using a third variable.
Question 8: ASCII Value
Accept a character from the user and display its ASCII (Unicode) value.
Example:
Input : A
Output : 65
Question 9: Currency Converter
Accept an amount in Indian Rupees (INR).
Convert it into US Dollars (USD).
Assume:
1 USD = ₹85
Question 10: Student Registration System
Create a console-based Student Registration program.
Accept the following details:
-
Name
-
Roll Number
-
Age
-
Department
-
Semester
-
Mobile Number
-
Email Address
Display all the information in a professional format.
Bonus Challenge
Create a Personal Profile Application.
The application should display:
-
Name
-
Date of Birth
-
Address
-
College Name
-
Branch
-
Semester
-
Skills
-
Hobbies
-
Career Goal
Design the output in a neat and attractive format using System.out.println().
Submission Guidelines
Before submitting your assignment, make sure:
-
All programs compile successfully.
-
There are no syntax errors.
-
Proper indentation is used.
-
Meaningful variable names are used.
-
Each program is saved with an appropriate file name.
Self-Evaluation Checklist
Before submitting, ask yourself:
-
Can I declare variables correctly?
-
Can I choose the correct data type?
-
Can I use arithmetic operators confidently?
-
Can I take user input using the Scanner class?
-
Can I perform type casting correctly?
-
Can I write a complete Java program without help?
If your answer is Yes to all the above questions, you are ready for the next module.
Module 2 Summary
In this module, you learned:
-
Variables
-
Primitive Data Types
-
Non-Primitive Data Types
-
Type Casting
-
Operators
-
User Input using Scanner
You also created several programs to strengthen your programming skills.
These concepts form the foundation of Java programming and will be used throughout the rest of this course.
What’s Next?
In the next module, you will learn how to make decisions in your programs using conditional statements.
Topics include:
-
ifStatement -
if-elseStatement -
Nested
if -
switchStatement -
Ternary Operator
-
Real-world decision-making programs
These concepts will allow your programs to make intelligent decisions based on user input.
Next Module: Module 3 – Decision Making Statements
Next Lesson: Lesson 3.1 – Introduction to Decision Making