☞ Programming in Java
NPTEL Week 01 : Programming Assignments Answers- 2025
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 Positive or Negative and print accordingly
// Start
if (number > 0) {
System.out.print("Positive");
}
else {
System.out.print("Negative");
}
// End
in.close();
}
}
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
// Start
double volume = Math.PI * (radius * radius) * height;
// End
// Display the result
System.out.printf("Volume is: %.2f", volume);
in.close();
}
}
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
// Start
for(int i =1; i < 5; i++) {
if (i != 4) {
System.out.println(number+" x "+i+" = "+(number * i));
}
else {
System.out.print(number+" x "+i+" = "+(number * i));
}
}
// End
in.close();
}
}
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
// Start
int quotient = x / y;
int remainder = x % y;
System.out.println("The Quotient is = "+quotient);
System.out.print("The Remainder is = "+remainder);
// End
sc.close();
}
}
import java.util.Scanner;
public class W01_P5 {
public static void main(String[] strings) {
double width ;
double height;
Scanner in = new Scanner(System.in);
width = in.nextDouble();
height = in.nextDouble();
// Start
// Calculate the perimeter of the rectangle
double perimeter = 2 * (width + height);
// Calculate the area of the rectangle
double area = (width * height);
// End
// Print the calculated perimeter using placeholders for values
System.out.printf("Perimeter is 2*(%.1f + %.1f) = %.2f\n", height, width, perimeter);
// Print the calculated area using placeholders for values
System.out.printf("Area is %.1f * %.1f = %.2f", width, height, area);
}
}
☞ NPTEL - Programming in Java - QUIZ : Week 1:Assignment 1 Answers- 2025
☞ NPTEL - Programming in Java - Week 01 : Programming Assignments Answers- 2025
☞ NPTEL - Programming in Java - QUIZ : Week 2:Assignment 2 Answers- 2025
☞ NPTEL - Programming in Java - Week 02 : Programming Assignments Answers- 2025
☞ NPTEL - Programming in Java - QUIZ : Week 3:Assignment 3 Answers- 2025
☞ NPTEL - Programming in Java - Week 03 : Programming Assignments Answers- 2025
☞ NPTEL - Introduction to Programming in C - Week 1:Assignment 1 Answers- 2025
☞ NPTEL - Introduction to Programming in C - Week 2:Assignment 2 Answers- 2025
☞ NPTEL - Introduction to Programming in C - Week 3:Assignment 3 Answers- 2025