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

Assignment

Uploaded by

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

Assignment

Uploaded by

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

Assignment Title: Exploring Java Programming Basics

Objective: The goal of this assignment is to understand the fundamental concepts


of Java programming including variables, data types, operators, control structures
(if-else, loops), and methods. By completing this assignment, you will gain practical
experience with the basic constructs of Java and develop problem-solving skills
using programming.

Instructions:
1. Part 1: Java Basics
Write a Java program to perform the following tasks:
a. Declare and initialize variables of different types (int, double, char, String).
b. Perform basic arithmetic operations (addition, subtraction, multiplication,
division) with two integers and print the results.
c. Use a conditional statement (if-else) to check whether a given integer is even or
odd.
d. Write a method that takes two integers as input, adds them, and returns the
result. Print the result in the main method.
2. Part 2: Control Structures and Loops
Write a Java program to:
a. Print all numbers from 1 to 10 using a for loop.
b. Write a program that uses a while loop to print the squares of numbers from 1 to
5.
c. Create a program that uses a do-while loop to print the first 5 numbers in the
Fibonacci sequence.
d. Use a switch-case statement to display the name of the day based on a number
input (1 for Monday, 2 for Tuesday, etc.).

You might also like