Assignment - Class 8 - Programming
Assignment — Programming (Java & BlueJ)
Practice, Code and Master Java Programming! This complete assignment covers Java basics — variables, data types, operators, input/output, and simple programs. Complete all three sections and aim for 100 marks!
Assignment Overview
- Total Marks: 100
- Section A (Theory): 30 marks
- Section B (Programs): 50 marks
- Section C (Output Prediction): 20 marks
- Language: Java (BlueJ IDE)
- Duration: 1 week
Motivational Message
This assignment is your gateway to becoming a programmer! Every question and program you complete builds your coding skills. Take it seriously, and you'll enjoy programming for life!
Objectives
Learning Goals
- ✅ Understand programming basics.
- ✅ Learn Java syntax and structure.
- ✅ Use variables and data types.
- ✅ Apply arithmetic and assignment operators.
- ✅ Handle input and output.
- ✅ Write and run Java programs in BlueJ.
Section A: Theory Questions (30 Marks)
Q1. What is programming? Name any two programming languages. (6 marks)
Programming is the process of writing instructions in a specific language that a computer can understand and execute to perform a task.
Examples of programming languages: Java, Python (or C, C++, JavaScript, etc.)
Q2. What is a variable? Give its syntax with an example. (6 marks)
A variable is a named storage location in memory that holds a value which can be changed during program execution.
Syntax: datatype variableName = value;
int age = 15;
String name = "Ravi";
double marks = 85.5;
char grade = 'A';
Q3. Name any four data types in Java with examples. (6 marks)
| Data Type | Description | Example |
|---|---|---|
int |
Whole numbers | int age = 15; |
double |
Decimal numbers | double price = 99.99; |
char |
Single character | char grade = 'A'; |
String |
Sequence of characters | String name = "Ravi"; |
boolean |
true or false | boolean isPass = true; |
Q4. What are arithmetic operators? List them with examples. (6 marks)
Arithmetic operators perform mathematical operations on values.
| Operator | Meaning | Example |
|---|---|---|
+ | Addition | 5 + 3 = 8 |
- | Subtraction | 5 - 3 = 2 |
* | Multiplication | 5 * 3 = 15 |
/ | Division | 10 / 2 = 5 |
% | Modulo (Remainder) | 10 % 3 = 1 |
Q5. What is the assignment operator? Give an example. (6 marks)
The assignment operator =
assigns the value on its right side to the variable on
its left side.
Example:
int age = 15; // Assigns 15 to age
double price = 99.99; // Assigns 99.99 to price
String name = "Ravi"; // Assigns "Ravi" to name
Compound assignment operators:
+=, -=, *=,
/=, %=
int x = 5;
x += 3; // Same as x = x + 3, now x = 8
Section B: Program Writing (50 Marks)
P1. Write a program to display "Hello, World!". (10 marks)
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Hello, World!
P2. Program to add two numbers entered by user. (10 marks)
import java.util.Scanner;
public class AddTwoNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter first number: ");
int a = sc.nextInt();
System.out.print("Enter second number: ");
int b = sc.nextInt();
int sum = a + b;
System.out.println("Sum = " + sum);
}
}
- Input: 10, 20 → Output: Sum = 30
- Input: 5, 7 → Output: Sum = 12
P3. Program to calculate area of a rectangle. (10 marks)
import java.util.Scanner;
public class RectangleArea {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter length: ");
double length = sc.nextDouble();
System.out.print("Enter breadth: ");
double breadth = sc.nextDouble();
double area = length * breadth;
System.out.println("Area of Rectangle = " + area);
}
}
- Input: 5, 4 → Output: Area = 20.0
- Input: 10.5, 3 → Output: Area = 31.5
P4. Program to convert temperature from Celsius to Fahrenheit. (10 marks)
import java.util.Scanner;
public class TemperatureConverter {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter temperature in Celsius: ");
double celsius = sc.nextDouble();
// Formula: F = (C * 9/5) + 32
double fahrenheit = (celsius * 9.0 / 5.0) + 32;
System.out.println("Temperature in Fahrenheit = " + fahrenheit);
}
}
- Input: 0 → Output: 32.0°F
- Input: 100 → Output: 212.0°F
- Input: 37 → Output: 98.6°F
P5. Program to check if a person is eligible to vote (age >= 18). (10 marks)
import java.util.Scanner;
public class VotingEligibility {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter your age: ");
int age = sc.nextInt();
if (age >= 18) {
System.out.println("You are eligible to vote!");
} else {
System.out.println("You are not eligible to vote.");
System.out.println("You need " + (18 - age) + " more years.");
}
}
}
- Input: 20 → Output: You are eligible to vote!
- Input: 15 → Output: You are not eligible to vote. You need 3 more years.
Section C: Output Prediction (20 Marks)
Q1. Predict the output. (4 marks)
int a = 10, b = 5;
System.out.println(a + b);
Q2. Predict the output. (4 marks)
int x = 10;
int y = 3;
System.out.println(x / y);
Q3. Predict the output. (4 marks)
int p = 15;
int q = 4;
System.out.println(p % q);
Q4. Predict the output. (4 marks)
String name = "Java";
System.out.println("Welcome to " + name);
Q5. Predict the output. (4 marks)
int m = 5;
m += 3;
System.out.println(m);
m += 3 is same as
m = m + 3. So m = 5 + 3 = 8.
Output Prediction Summary
| Question | Answer | Reason |
|---|---|---|
| Q1 | 15 | 10 + 5 |
| Q2 | 3 | Integer division: 10/3 |
| Q3 | 3 | 15 % 4 = remainder 3 |
| Q4 | Welcome to Java | String concatenation |
| Q5 | 8 | 5 + 3 = 8 |
Submission Format
How to Submit
- ✅ Handwritten in notebook OR typed in A4 sheets.
- ✅ Java code with proper indentation.
- ✅ Include test cases and outputs.
- ✅ Screenshots of BlueJ outputs (if possible).
- ✅ Clean handwriting/formatting.
- ✅ Submit on time.
- ✅ Include your name, roll number, class.
Evaluation Criteria (Total: 100 Marks)
| Section | Marks |
|---|---|
| Section A (Theory) | 30 |
| Section B (Programs) | 50 |
| Section C (Output) | 20 |
| Total | 100 |
Tips for Success
Best Practices
- 📖 Read each question carefully.
- 📝 Write neat, readable code.
- 📐 Use proper indentation.
- 💬 Add comments to explain your logic.
- 🧪 Test each program with different inputs.
- 🎯 Follow Java naming conventions.
- ✏️ Double-check syntax before submitting.
- 📅 Start early, don't wait until the last minute.
- 👨🏫 Ask your teacher if you get stuck.
- 🔄 Practice similar programs beforehand.
Common Mistakes to Avoid
Watch Out for These!
- ❌ Missing semicolons (;)
- ❌ Missing braces { }
- ❌ Incorrect class name (must match file name)
- ❌ Not importing Scanner (for input)
- ❌ Case-sensitive errors (Java is case-sensitive)
- ❌ Using wrong data type
- ❌ Integer division confusion
- ❌ Forgetting to compile before running
How to Run Programs in BlueJ
Create New Project
Open BlueJ → Project → New Project → Choose location.
Create New Class
Click "New Class" → Enter class name (same as file) → OK.
Write Java Code
Double-click class → Delete default → Type your code.
Compile & Run
Click "Compile" → Fix errors → Right-click → main() → OK.
Suggested Timeline (1 Week)
| Day | Tasks |
|---|---|
| Day 1 | Theory Questions (Q1-Q3) |
| Day 2 | Theory Questions (Q4-Q5) |
| Day 3 | Programs P1-P2 (Hello World, Add) |
| Day 4 | Programs P3-P4 (Area, Temperature) |
| Day 5 | Program P5 (Voting) |
| Day 6 | Output Prediction (Q1-Q5) |
| Day 7 | Review, organize, and submit! |
Did You Know?
Fun Fact
Java was created in 1995 by James Gosling at Sun Microsystems! It was originally called "Oak" but was later renamed to "Java" — after the coffee. Today, Java runs on over 3 billion devices worldwide!
Bonus Challenges (Optional)
Extra Practice
- 🌟 Write a program to calculate simple interest (SI = P × R × T / 100).
- 🌟 Write a program to swap two numbers using a temporary variable.
- 🌟 Write a program to check if a number is even or odd.
- 🌟 Write a program to find the square of a number.
- 🌟 Write a program to calculate the perimeter of a rectangle.
- 🌟 Write a program to find the average of three numbers.
- 🌟 Write a program to check if a year is a leap year.
- 🌟 Write a program to convert kilometers to miles.
Frequently Asked Questions
Q1. Can I use my own variable names?
Yes! Use meaningful names. Follow camelCase (like studentName).
Q2. What if my program has errors?
Read the error message carefully. Common issues: missing semicolons, wrong case, or missing braces.
Q3. Should I add comments?
Yes! Comments earn marks and show understanding. Use
// for single-line comments.
Q4. How many test cases should I show?
At least 2-3 different test cases showing your program works for various inputs.
Q5. Can I use Notepad instead of BlueJ?
Yes, but BlueJ is easier for beginners because of its visual interface. Ask your teacher's preference.
Q6. What if I don't understand a question?
Ask your teacher or a classmate for clarification. Don't guess — understand first.
Q7. Should I write the class name same as file name?
YES! In Java, if you use public class, the
class name MUST match the file name (case-sensitive).
Q8. Can I use online IDE like Replit?
Yes, but BlueJ is standard for ICSE Class 8. If BlueJ isn't available, ask your teacher.
Key Takeaways
- Complete all 3 sections for full 100 marks.
- Section A: Theory (30 marks).
- Section B: 5 Java programs (50 marks).
- Section C: 5 output predictions (20 marks).
- Use proper syntax and indentation.
- Test programs with multiple inputs.
- Add comments to explain code.
- Try bonus challenges for extra practice.
- Submit on time with proper format.
- Learn while you complete!
Key Takeaway
Practice, Code, and Master Java
Programming! Every program you write brings
you closer to being a great programmer.
This assignment covers all the essential Java basics.
Complete it thoroughly and you'll have a strong
foundation to tackle more complex programming challenges
ahead!
Complete all sections. Give your best effort.
You will excel in programming!
⭐ CODE SMART, THINK CLEAR, WRITE BETTER! ⭐
Best of Luck! Practice daily, understand
deeply, and code confidently! 👍😊
Flowchart → Visual Thinking → Smart Solutions → Better
Results! 🚀
Home & Online Tuition
Learn from an experienced tutor with personalized guidance.
Available Locations
Expert Home & Online Tuition
Personalized one-to-one tuition that focuses on concept building, practical learning, problem-solving skills, and excellent academic performance. Suitable for school students looking for structured, interactive, and result-oriented learning.
Subjects We Teach
Why Choose Our Tuition?
✅ Concept-Based Learning
✅ Practical Examples
✅ Weekly Tests
✅ Doubt Solving Sessions
✅ Practice Worksheets
✅ MCQ & Assignments
✅ Exam Preparation
✅ Flexible Class Timings