Nptel Programming in Java Week 1 Assignment Answers

Programming In Java

ABOUT THE COURSE :
With the growth of Information and Communication Technology, there is a need to develop large and complex software. Further, those software should be platform independent, Internet enabled, easy to modify, secure, and robust. To meet this requirement object-oriented paradigm has been developed and based on this paradigm the Java programming language emerges as the best programming environment. Now, Java programming language is being used for mobile programming, Internet programming, and many other applications compatible to distributed systems. This course aims to cover the essential topics of Java programming so that the participants can improve their skills to cope with the current demand of IT industries and solve many problems in their own filed of studies.
INTENDED AUDIENCE :  The undergraduate students from the engineering disciplines namely CSE, IT, EE, ECE, etc. might be interested for this course.

PREREQUISITES :  
This course requires that the students are familiar with programming language such as C/C++ and data structures, algorithms.

INDUSTRY SUPPORT : 
  All IT companies.

Nptel Programming in Java Week 1 Assignment Answers

Course layout

Week 1  :  Overview of Object-Oriented Programming and Java
Week 2  :  Java Programming Elements
Week 3  :  Input-Output Handling in Java
Week 4  :  Encapsulation
Week 5  :  Inheritance
Week 6  :  Exception Handling
Week 7  :  Multithreaded Programming
Week 8  :  Java Applets and Servlets
Week 9  :  Java Swing and Abstract Windowing Toolkit (AWT)
Week 10 : Networking with Java
Week 11 :  Java Object Database Connectivity (ODBC)
Week 12 :  Interface and Packages for Software Development

Nptel Programming in Java Week 1 Assignment Answers

Week 1 Assignment 1

Due date: 2025-02-05, 23:59 IST.
Assignment not submitted
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 

 

Week 01 : Programming Assignment 1

Due on 2025-02-06, 23:59 IST

Write a Java program to check if a given integer is even or odd.

 

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.

(Ignore presentation errors for this and all future programming assignments)
(“passed with presentation error” means you will get full marks)

Your last recorded submission was on 2025-01-15, 16:23 IST

Select the Language for this assignment. 

File name for this program :

import java.util.Scanner;

public class W01_P1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int number = in.nextInt();
// Check if the number is even or odd
if (number % 2 == 0) {
  System.out.print("Even");
} else {
  System.out.print("Odd");
}
in.close();
    }
}



 
 

Public Test Cases Input Expected Output Actual Output Status
Test Case 1
4
Even
Even
Passed
 

Week 01 : Programming Assignment 2

Due on 2025-02-06, 23:59 IST

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

Formula:

V=π×r2×h

�=π×�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)

(Ignore presentation errors for this and all future programming assignments)
(“passed with presentation error” means you will get full marks)

Your last recorded submission was on 2025-01-15, 16:25 IST

Select the Language for this assignment. 

File name for this program :

import java.util.Scanner;

public class W01_P2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double radius = in.nextDouble();
        double height = in.nextDouble();
// Calculate the volume
double volume = Math.PI * radius * radius * height;
// Display the result
    System.out.printf("Volume is: %.2f", volume);
    in.close();
  }
}



 
 

Public Test Cases Input Expected Output Actual Output Status
Test Case 1
3.5
5.0
Volume is: 192.42
Volume is: 192.42
Passed
 

Week 01 : Programming Assignment 3

Due on 2025-02-06, 23:59 IST

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

 

NOTE:

Print EXACTLY as shown in the sample output.

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


(Ignore presentation errors for this and all future programming assignments)
(“passed with presentation error” means you will get full marks)

Your last recorded submission was on 2025-01-15, 16:28 IST

Select the Language for this assignment. 

File name for this program :

import java.util.Scanner;

public class W01_P3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int number = in.nextInt();
// Print the multiplication table of number up to 5
for (int i = 1; i <= 4; i++) {
   System.out.println(number + " x " + i + " = " + (number * i));
}
System.out.print(number + " x " + 5 + " = " + (number * 5));
in.close();
    }
}



 
 

Public Test Cases Input Expected Output Actual Output Status
Test Case 1
5
5 x 1 = 5n
5 x 2 = 10n
5 x 3 = 15n
5 x 4 = 20n
5 x 5 = 25
5 x 1 = 5n
5 x 2 = 10n
5 x 3 = 15n
5 x 4 = 20n
5 x 5 = 25
Passed
 

Week 01 : Programming Assignment 4

Due on 2025-02-06, 23:59 IST

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

(Ignore presentation errors for this and all future programming assignments)
(“passed with presentation error” means you will get full marks)

Your last recorded submission was on 2025-01-15, 16:36 IST

Select the Language for this assignment. 

File name for this program :

import java.util.Scanner;
public class W01_P4{
       public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int x=sc.nextInt();
       int y=sc.nextInt();
//code for quotient and remainder
if (y == 0) {
  System.out.println("Error: Division by zero is not allowed.");
}
else {
  int quotient = x / y;
  int remainder = x % y;
  System.out.println("The Quotient is = " + quotient);
  System.out.print("The Remainder is = " + remainder);
}
sc.close();
  }
}



 
 

Public Test Cases Input Expected Output Actual Output Status
Test Case 1
556
9
The Quotient is = 61n
The Remainder is = 7
The Quotient is = 61n
The Remainder is = 7
Passed
 

Week 01 : Programming Assignment 5

Due on 2025-02-06, 23:59 IST

Write a program which will print a pattern of “*” ‘s of height “n”.
For example:
Input:
               n = 3
Output:
               ***
               **
               *
               **
               ***

NOTE:
Print the pattern EXACTLY, without extra spaces.

(Ignore presentation errors for this and all future programming assignments)
(“passed with presentation error” means you will get full marks)

Your last recorded submission was on 2025-01-15, 16:53 IST

Select the Language for this assignment. 

File name for this program :

import java.util.*;
public class W01_P5{
    public static void main(String[] args) {
        Scanner inr = new Scanner(System.in);
       int n = inr.nextInt();
// Add the necessary code in the below space
for(int i = n; i >= 1; i--) {
  for(int j = 1; j <= i; j++) {
    System.out.print("*");
  }
  System.out.println();
}
for(int i = n-1; i >= 1; i--) {
  for(int j = 1; j <= n-i+1; j++) {
    System.out.print("*");
  }
  if ( i != 1 )
    System.out.println();
}
inr.close();
    }
}



 
 

Public Test Cases Input Expected Output Actual Output Status
Test Case 1
6
******n
*****n
****n
***n
**n
*n
**n
***n
****n
*****n
******
******n
*****n
****n
***n
**n
*n
**n
***n
****n
*****n
******
Passed
 

 

Related Posts

Leave a Reply