Home

Learn Programming & Prepare for NPTEL Exams... Swayam Solver is your one-stop destination for NPTEL exam preparation.

NPTEL Programming In Java Programming Assignment July-2022 Swayam

 


NPTEL » Programming In Java     July 2022 NPTEL course


Scroll Down for latest Assignments


Support me : Subscribe to the YouTube Channel :  Swayam Solver


Week 1: Programming Assignment 1

Due on 2022-08-11, 23:59 IST

Complete the code segment to find the perimeter and area of a circle given a value of radius.

You should use Math.PI constant in your program. If radius is zero or less than zero then print " please enter non zero positive number ".

Your last recorded submission was on 2022-07-30, 16:38 IST
Select the Language for this assignment. 
File name for this program : 
1
import java.util.Scanner;  
public class Exercise1_1 {
       public static void main(String[] args) {
Scanner s = new Scanner(System.in); 
       double radius= s.nextDouble();
       double perimeter;
       double area;
if( radius <= 0)
  System.out.println(" please enter non zero positive number ");
perimeter = 2*Math.PI*radius;   //Calculate the perimeter 
area = Math.PI*radius*radius;    //Calculate the area
System.out.println("" +perimeter);
System.out.print("" + area);
0
  }
1
}
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
2.5
15.707963267948966\n
19.634954084936208
15.707963267948966\n
19.634954084936208
Passed

Private Test cases used for EvaluationStatus
Test Case 1
Passed




Week 1 : Programming Assignment 2

Due on 2022-08-11, 23:59 IST

Complete the code segment to find the largest among three numbers x,y, and z. You should use if-then-else construct in Java.

Your last recorded submission was on 2022-07-30, 16:46 IST
Select the Language for this assignment. 
File name for this program : 
1
import java.util.Scanner;  
2
public class Exercise1_2 {
3
       public static void main(String[] args) {
4
Scanner s = new Scanner(System.in); 
5
        int x = s.nextInt(); 
6
        int y = s.nextInt();
7
int z = s.nextInt();
8
int result = 0;
9
//Use if...else ladder to find the largest among 3 numbers and store the largest number in a variable called result.
if ( x > y)
  if(x > z)
    result = x;
  else
    result = z;
else if(y > z)
    result = y;
  else
    result = z;
System.out.print(result) ;
0
 }
1
}
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 -2 -3
-2
-2
Passed

Private Test cases used for EvaluationStatus
Test Case 1
Passed
Test Case 2
Passed




Week 1 : Programming Assignment 3

Due on 2022-08-11, 23:59 IST

Consider First n even numbers starting from zero(0).Complete the code segment to calculate sum of  all the numbers divisible by 3 from 0 to n. Print the sum.

Example:

Input: n = 5

-------
0 2 4 6 8
Even number divisible by 3:0 6
sum:6

Your last recorded submission was on 2022-07-30, 17:34 IST
Select the Language for this assignment. 
File name for this program : 
1
import java.util.Scanner;
2
public class Exercise1_3 {
3
       public static void main(String[] args) {
4
       Scanner sc = new Scanner(System.in);
5
       int n=sc.nextInt();
6
      int sum=0;
7
//Use for or while loop do the operation.
int even_num = 0, match = 0;
for( int i=0; i <= n ; i++ ) {
  if ( even_num % 3 == 0) {
    sum+= even_num ;
    match ++;
  }
  even_num = even_num+2 ;
}
System.out.print(sum);
0
  }
1
}
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
1
0
0
Passed


Private Test cases used for EvaluationStatus
Test Case 1
Passed
Test Case 2
Passed





Week 1 : Programming Assignment 4

Due on 2022-08-11, 23:59 IST

Complete the code segment to check whether the number is an Armstrong number or not.

Armstrong Number:

A positive number is called an Armstrong number if it is equal to the sum of cubes of its digits for example 153 = 1
3+53+33, 370, 371, 407, etc.

Your last recorded submission was on 2022-07-30, 17:43 IST
Select the Language for this assignment. 
File name for this program : 
1
import java.util.Scanner;
2
public class Exercise1_4 {
3
    public static void main(String[] args) {
4
       Scanner sc = new Scanner(System.in);
5
       int n=sc.nextInt();
6
           int result=0;
//Use while loop check the number is Armstrong or not.
//store the output(1 or 0) in result variable.
int N = n;
int sum = 0;
while (N!=0) {
  sum += (N%10)*(N%10)*(N%10);
  N/=10;
}
if(sum == n )
  result = 1;
else
  result = 0;
System.out.print(result) ;
0
 }
1
}
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
203
0
0
Passed


Private Test cases used for EvaluationStatus
Test Case 1
Passed
Test Case 2
Passed




Week 1 : Programming Assignment 5

Due on 2022-08-11, 23:59 IST

Complete the code segment to help Ragav , find the highest mark and average mark secured by him in "s" number of subjects.

Your last recorded submission was on 2022-07-30, 17:54 IST
Select the Language for this assignment. 
File name for this program : 
1
import java.util.Scanner;
2
public class Exercise1_5{
3
    public static void main(String[] args) {
4
     Scanner input = new Scanner(System.in);
5
         double mark_avg;
6
         int result;
7
         int i;
8
         int s;
9
      //define size of array
10
       s = input.nextInt();
11
     //The array is defined "arr" and inserted marks into it.
12
      int[] arr = new int[s];   
13
      for(i=0;i<arr.length;i++)
14
      {
15
    arr[i]=input.nextInt();
16
        }
//Initialize maximum element as first element of the array.  
   //Traverse array elements to get the current max.
   //Store the highest mark in the variable result.
   //Store average mark in avgMarks.
result = arr[0];
mark_avg = 0;
for(i=0;i<arr.length;i++)
    {
        if ( arr[i] > result )
          result = arr[i];
        mark_avg+=arr[i];
    }
mark_avg = mark_avg/arr.length;
System.out.println(result) ;
System.out.print(mark_avg) ;
0
 }
1
}
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
20 50 60 40 70
70\n
48.0
70\n
48.0
Passed


Private Test cases used for EvaluationStatus
Test Case 1
Passed
Test Case 2
Passed



----------------------------------------------------------------------------------------------------------------------------




Week 2 : Programming Assignment 1

Due on 2022-08-11, 23:59 IST
Complete the code segment to call the method  print() of class Student first and then call print() method of class School.

NOTE: Don't provide any INPUT in Sample Test Cases

Your last recorded submission was on 2022-08-08, 21:02 IST
Select the Language for this assignment. 
File name for this program : 
1
// This is the class named School
2
class School { 
3
    // This is a method in class School
4
    public void print() { 
5
        System.out.println("Hi! I class SCHOOL."); 
6
    } 
7
} 
8
// This is the class named Student
9
class Student { 
10
    // This is a method in class Student
11
    public void print() { 
12
        System.out.println("Hi! I am class STUDENT"); 
13
    } 
14
}
15
16
public class Question21{ 
17
    public static void main(String args[]){
18
// Create an object of class Student
Student stu = new Student();
// Call 'print()' method of class Student 
stu.print();
// Create an object of class School
School sch = new School();
// Call 'print()' method of class School
sch.print();
0
~~~THERE IS SOME INVISIBLE CODE HERE~~~
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
NA
Hi! I am class STUDENT\n
Hi! I class SCHOOL.
Hi! I am class STUDENT\n
Hi! I class SCHOOL.\n
Passed after ignoring Presentation Error



Private Test cases used for EvaluationStatus
Test Case 1
Passed





Week 2 : Programming Assignment 2

Due on 2022-08-11, 23:59 IST
Complete the code segment to call the method  print() of class given class Printer to print the following.

--------------------------------
Hi! I am class STUDENT
Hi! I class SCHOOL.
--------------------------------

NOTE: Don't provide any INPUT in Sample Test Cases

Your last recorded submission was on 2022-08-08, 21:02 IST
Select the Language for this assignment. 
File name for this program : 
1
// This is the class named Printer
2
class Printer { 
3
    // This are the methods in class Printer
4
    public void print() { 
5
        System.out.println("Hi! I class SCHOOL."); 
6
    } 
7
    public void print(String s) { 
8
        System.out.println(s); 
9
    } 
10
} 
11
12
public class Question22{ 
13
    public static void main(String[] args) {    
14
// Create an object of class Printer
Printer pri = new Printer();
// Call 'print()' methods for desired output
pri.print("Hi! I am class STUDENT");
pri.print();
0
    }
1
}
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
NA
Hi! I am class STUDENT\n
Hi! I class SCHOOL.
Hi! I am class STUDENT\n
Hi! I class SCHOOL.\n
Passed after ignoring Presentation Error




Private Test cases used for EvaluationStatus
Test Case 1
Passed






Week 2 : Programming Assignment 3

Due on 2022-08-11, 23:59 IST
Complete the code segment to call print() method of class Question by creating a method named ‘studentMethod()’.
Your last recorded submission was on 2022-08-08, 21:03 IST
Select the Language for this assignment. 
File name for this program : 
1
// This is the main class Question
2
public class Question23{ 
3
    public static void main(String[] args) { 
4
        // Object of the main class is created
5
        Question23 q = new Question23();
6
        // Print method on object of Question class is called
7
        q.studentMethod();
8
    }
9
    
10
    // 'print()' method is defined in class Question
11
    void print(Question23 object){
12
        System.out.print("Well Done!");
13
    }
14
// Define a method named 'studentMethod()' in class Question
void studentMethod(){
// Call the method named 'print()' in class Question
    print(this);
}
0
}
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
NA
Well Done!
Well Done!
Passed




Private Test cases used for EvaluationStatus
Test Case 1
Passed




Week 2 : Programming Assignment 4

Due on 2022-08-11, 23:59 IST
Complete the code segment to call default constructor first and then any other constructor in the class.
Your last recorded submission was on 2022-08-08, 21:04 IST
Select the Language for this assignment. 
File name for this program : 
1
// This is the main class Question
2
public class Question214{
3
    public static void main(String[] args){
4
        Answer a = new Answer(10,"MCQ");
5
    }
6
}
7
class Answer{
    Answer(){
        System.out.println("You got nothing.");
    }
    Answer(int marks, String type){ 
      this();
        System.out.print("You got "+marks+" for an "+ type);
    }
}

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
NA
You got nothing.\n
You got 10 for an MCQ
You got nothing.\n
You got 10 for an MCQ
Passed



Private Test cases used for EvaluationStatus
Test Case 1
Passed





Week 2 : Programming Assignment 5

Due on 2022-08-11, 23:59 IST
Complete the code segment to debug / complete the program which is intended to print 'NPTEL JAVA'.
Your last recorded submission was on 2022-08-08, 21:04 IST
Select the Language for this assignment. 
File name for this program : 
1
public class Question215{ 
2
    public static void main(String[] args) { 
3
4
//Declare variable with name 'nptel', 'space' and 'java' and proper datatype.
String nptel;
String space;
String java;
//Initialize the variables with proper input
nptel = new String("NPTEL");
space = new String(" ");
java = new String("JAVA");
0
     System.out.print(nptel+space+java);
1
   }
2
}
3
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
NA
NPTEL JAVA
NPTEL JAVA
Passed



Private Test cases used for EvaluationStatus
Test Case 1
Passed






















































































Please subscribe to our YouTube Channel :  Swayam Solver

This will help the creator to continue making quality content...

Have a great day !























No comments:

Post a Comment

Keep your comments reader friendly. Be civil and respectful. No self-promotion or spam. Stick to the topic. Questions welcome.