Home

Swayam Solver

Learn Programming & Prepare for NPTEL Exams...

Find your course

Explore Courses

Latest Blog Posts

NPTEL Programming In Java Programming Assignment July-2025 Swayam

NPTEL » Programming In Java



  Please scroll down for latest Programs. ðŸ‘‡  



Week 01 : Programming Assignment 1

Due on 2025-08-07, 23:59 IST

Write a Java program to check if a given integer is “Positive” or “Negative”.

(0 (Zero) should be considered positive by this program.)

 

NOTE:

The code you see is not complete.

Your task is to complete the code as per the question.
Think of it like a programming puzzle.

 

(Remember to match the output given exactly, including the spaces and new lines)

(Passed with presentation error means you will get full marks)

Your last recorded submission was on 2025-07-24, 10:13 IST
Select the Language for this assignment. 
File name for this program : 
1
import java.util.Scanner;
2
3
public class W01_P1 {
4
    public static void main(String[] args) {
5
        Scanner in = new Scanner(System.in);
6
        int number = in.nextInt();
7
// Check if the number is Positive or Negative and print accordingly
8
if (number >= 0) {
9
  System.out.print("Positive");
10
} else {
11
  System.out.print("Negative");
12
}
0
in.close();
1
    }
2
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
4
Positive
Positive
Passed
Test Case 2
-3
Negative
Negative
Passed



Week 01 : Programming Assignment 2

Due on 2025-08-07, 23:59 IST

Write a Java program to calculate the volume of a cylinder given its radius and height.

Formula:

=2ℎ

You can use Math.PI for the computation.

NOTE:

The code you see is not complete.

Your task is to complete the code as per the question.
Think of it like a programming puzzle.

(This question can be solved in just one line of code)


Your last recorded submission was on 2025-07-24, 10:15 IST
Select the Language for this assignment. 
File name for this program : 
1
import java.util.Scanner;
2
3
public class W01_P2 {
4
    public static void main(String[] args) {
5
        Scanner in = new Scanner(System.in);
6
        double radius = in.nextDouble();
7
        double height = in.nextDouble();
8
// Calculate the volume
9
double volume = Math.PI * radius * radius * height;
0
// Display the result
1
    System.out.printf("Volume is: %.2f", volume);
2
    in.close();
3
  }
4
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
3.5
5.0
Volume is: 192.42
Volume is: 192.42
Passed



Week 01 : Programming Assignment 3

Due on 2025-08-07, 23:59 IST

Write a Java program to print the multiplication table of a given number up to 4.

 

NOTE:

Print EXACTLY as shown in the sample output.

DO NOT MISS a single space otherwise you will not be scored.

(Remember to match the output given exactly, including the spaces and new lines)

(passed with presentation error means you will get full marks)

Your last recorded submission was on 2025-07-24, 10:16 IST
Select the Language for this assignment. 
File name for this program : 
1
import java.util.Scanner;
2
3
public class W01_P3 {
4
    public static void main(String[] args) {
5
        Scanner in = new Scanner(System.in);
6
        int number = in.nextInt();
7
// Print the multiplication table of number up to 5
8
for (int i = 1; i <= 4; i++)
9
  System.out.printf("%d x %d = %d\n", number, i, number * i);
0
in.close();
1
    }
2
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
5
5 x 1 = 5\n
5 x 2 = 10\n
5 x 3 = 15\n
5 x 4 = 20
5 x 1 = 5\n
5 x 2 = 10\n
5 x 3 = 15\n
5 x 4 = 20\n
Passed after ignoring Presentation Error



Week 01 : Programming Assignment 4

Due on 2025-08-07, 23:59 IST

Complete the code fragment that reads two integer inputs from keyboard and compute the quotient and remainder.

Your last recorded submission was on 2025-07-24, 10:18 IST
Select the Language for this assignment. 
File name for this program : 
1
import java.util.Scanner;
2
public class W01_P4{
3
       public static void main(String[] args) {
4
       Scanner sc = new Scanner(System.in);
5
       int x=sc.nextInt();
6
       int y=sc.nextInt();
7
//code for quotient and remainder
8
if (y == 0) {
9
  System.out.println("Error: Division by zero is not allowed.");
10
}
11
else {
12
  int quotient = x / y;
13
  int remainder = x % y;
14
  System.out.println("The Quotient is = " + quotient);
15
  System.out.print("The Remainder is = " + remainder);
16
}
0
sc.close();  
1
  }
2
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
556
9
The Quotient is = 61\n
The Remainder is = 7
The Quotient is = 61\n
The Remainder is = 7
Passed



Week 01 : Programming Assignment 5

Due on 2025-08-07, 23:59 IST

Write a Java program to print the area and perimeter of a rectangle.

Your last recorded submission was on 2025-07-24, 10:19 IST
Select the Language for this assignment. 
File name for this program : 
1
import java.util.Scanner;
2
public class W01_P5 { 
3
   public static void main(String[] strings) {
4
       double width ;
5
       double height;
6
       Scanner in = new Scanner(System.in);
7
       width = in.nextDouble();
8
       height = in.nextDouble();
9
// Calculate the perimeter of the rectangle
10
double perimeter = 2 * ( height + width ) ;
11
// Calculate the area of the rectangle
12
double area = height * width;
0
// Print the calculated perimeter using placeholders for values
1
       System.out.printf("Perimeter is 2*(%.1f + %.1f) = %.2f\n", height, width, perimeter);
2
3
// Print the calculated area using placeholders for values
4
       System.out.printf("Area is %.1f * %.1f = %.2f", width, height, area);    
5
   }
6
}
You may submit any number of times before the due date. The final submission will be considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program , your assignment will not be graded and you will not see your score after the deadline.
   


 
 
Public Test CasesInputExpected OutputActual OutputStatus
Test Case 1
5.6 8.5
Perimeter is 2*(8.5 + 5.6) = 28.20\n
Area is 5.6 * 8.5 = 47.60
Perimeter is 2*(8.5 + 5.6) = 28.20\n
Area is 5.6 * 8.5 = 47.60
Passed