[go: up one dir, main page]

0% found this document useful (0 votes)
5 views6 pages

Holiday Homework

The document outlines holiday homework for Class IX students at Saint Paul's High School, focusing on Java programming concepts such as values, data types, operators, and methods. Students are required to complete five programming tasks using BlueJ, including creating an even/odd checker, temperature converter, number swapper, simple calculator, and simple interest calculator. Each program must be documented with screenshots and explanations, and students are reminded to write their own code and avoid common mistakes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Holiday Homework

The document outlines holiday homework for Class IX students at Saint Paul's High School, focusing on Java programming concepts such as values, data types, operators, and methods. Students are required to complete five programming tasks using BlueJ, including creating an even/odd checker, temperature converter, number swapper, simple calculator, and simple interest calculator. Each program must be documented with screenshots and explanations, and students are reminded to write their own code and avoid common mistakes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

SAINT PAUL'S HIGH SCHOOL, BATHINDA

(A 10+2 Institution Permanently Affiliated to CISCE, New Delhi)

Java Programming Holiday Homework - Class IX

Topic: Values, Data Types, Operators, and Introduction to Methods

Software Required: BlueJ

Installation Instructions:

1.​ Visit www.bluej.org


2.​ Click on "Download" button
3.​ Select your operating system (Windows/Mac/Linux)
4.​ Download and run the installer
5.​ Follow the installation wizard steps
6.​ BlueJ is completely free to download and use

General Instructions

1.​ Create a new BlueJ project named HolidayHomework_YourName


2.​ Write each program in a separate class (5 classes total)
3.​ Include simple comments in your code
4.​ Take screenshots of:
○​ Your code in BlueJ editor
○​ Output in BlueJ terminal window
5.​ Paste everything in a neat project file
6.​ Screenshots can be black and white (color printing not required)

Problem 1: Even or Odd Checker


Learning Goal: Practice using the ternary operator

Write a Java program that:

●​ Declares an integer variable with a value (e.g., int number = 25;)


●​ Uses the ternary operator to check if it's even or odd
●​ Prints the result
●​ Run the program twice: once with an even number, once with an odd number

Class name: EvenOddChecker

Run with: number = 25 (odd) and number = 18 (even)

Problem 2: Temperature Converter


Learning Goal: Practice arithmetic operators and data types

Write a Java program that:

●​ Declares a double variable fahrenheit with a temperature value


●​ Converts it to Celsius using the formula: (fahrenheit - 32) * 5.0 / 9.0
●​ Prints both temperatures

Class name: TemperatureConverter

Hint: Use double data type for decimal values!

Expected Output Example:

Temperature in Fahrenheit: 100.0


Temperature in Celsius: 37.77777777777778

Problem 3: Number Swapper


Learning Goal: Understanding how to swap values using arithmetic operators

Write a Java program that:

●​ Declares two integer variables (e.g., int a = 10; int b = 20;)


●​ Prints their values before swapping
●​ Swaps them WITHOUT using a third variable (use arithmetic operators)
●​ Prints their values after swapping

Class name: NumberSwapper


Hint for swapping without third variable:

a = a + b;
b = a - b;
a = a - b;

Problem 4: Simple Calculator with Methods (Introduction to Methods)


Learning Goal: Writing your first method

Create a simple calculator that uses methods for calculations:

Class name: SimpleCalculator

Program Structure:

public class SimpleCalculator​


{​
// Method to add two numbers​
public static int add(int x, int y)​
{​
return x + y;​
}​

// Method to subtract two numbers​
public static int subtract(int x, int y)​
{​
return x - y;​
}​

// Main method​
public static void main(String[] args)​
{​
int num1 = 15;​
int num2 = 7;​

// Call the methods and print results​
int sum = add(num1, num2);​
int sub = subtract(num1, num2);
System.out.println(“Sum is: ” + sum);
System.out.println(“Sub is: “ + sub);​
}​
}
Your Task:

●​ Complete the above code


●​ Add two more methods: multiply and divide
●​ Call all four methods in the main method

Problem 5: Simple Interest Calculator


Learning Goal: Working with different data types and arithmetic operators

Write a Java program that:

●​ Calculates simple interest using the formula: SI = (P × R × T) / 100


●​ Where P = Principal amount, R = Rate of interest, T = Time in years
●​ Use appropriate data types for each variable
●​ Display the total amount (Principal + Interest)

Class name: SimpleInterest

Example values to use:

double principal = 1000.0; // Rs. 1000​


double rate = 8.5; // 8.5% per year​
int time = 2; // 2 years

Expected Output Example:

Principal Amount: Rs. 1000.0


Rate of Interest: 8.5%
Time Period: 2 years
Simple Interest: Rs. 170.0
Total Amount: Rs. 1170.0

How to Work in BlueJ


Creating a New Class:

1.​ Open BlueJ


2.​ Create New Project (Project → New Project)
3.​ Right-click in the project window → New Class
4.​ Type the class name → OK
5.​ Double-click the class to open editor

Running Your Program:

1.​ Click "Compile" button


2.​ Right-click on the class → void main(String[] args)
3.​ Click "OK" to run
4.​ See output in Terminal Window

Taking Screenshots:

1.​ For code: Take screenshot of the editor window


2.​ For output: Take screenshot of the Terminal Window
3.​ Use Windows: Windows Key + Shift + S or Mac: Command + Shift + 4
4.​ Note: Screenshots can be printed in black and white - color is not required

Project File Format

What to Submit:

1.​ Cover Page​

○​ Name: ________________
○​ Class: IX
○​ Section: ___
○​ Roll Number: ___
○​ Subject: Computer Applications
2.​ For Each Program:​

○​ Problem number and statement


○​ Screenshot of code in BlueJ
○​ Screenshot of output (show at least 2 different test runs for Problem 1)
○​ Brief explanation (2-3 lines about what the program does)
○​ Note: All screenshots can be in black and white
3.​ What I Learned (Write 5-6 lines about):​

○​ What is a ternary operator?


○​ What are methods in Java?
○​ Why are different data types (int, double) important?

Important Reminders

Data Types to Remember:

●​ int - for whole numbers (10, -5, 0)


●​ double - for decimal numbers (3.14, 98.6)
●​ String - for text ("hello", "even")

Operators You'll Use:

●​ Arithmetic: +, -, *, /, %
●​ Ternary: condition ? value1 : value2
●​ Assignment: =

Tips:

●​ Start each program with the class structure BlueJ provides


●​ Don't forget semicolons (;) at the end of statements
●​ Use meaningful variable names
●​ Test your programs before taking screenshots

Common Mistakes to Avoid:

●​ Forgetting to compile before running


●​ Using int for decimal values (use double instead)
●​ Missing semicolons
●​ Incorrect class names (must match file name)

Note: Write your own code. You can discuss with friends but copying will result in zero marks.

Enjoy coding during your holidays!

You might also like