NPTEL Programming In Java Assignment 1 Answers 2022

NPTEL Programming In Java Assignment 1 Answers 2022:- All the Answers provided here to help the students as a reference, You must submit your assignment at your own knowledge

1. Consider the following program.

What will be the output of the program if it is executed?

a. 15
b. 12
C. 14
d. 10

public class Question { 
        public static void main (String args [1) { 
                 for (int b=7;b>3;b-=5) { 
                            System.out.print (b+++b);
                }
        }
}
Answer:-

More Answers Of This week :- CLICK HERE

What is Programming In Java?

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.

CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the average of best 8 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100

Final score = Average assignment score + Exam score

YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF THE AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.

Below you can find the answers for Programming In Java Assignment 1

Programming In Java Assignment 1 Answers:-

Q1. 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 “.

Code:-

 System.out.println(2*Math.PI*radius);
 System.out.print(radius*Math.PI*radius);

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

Code:-

if (x>y && x>z)
System.out.print(x);
else if (y>x && y>z)
System.out.print(y);
  else
  System.out.println(z);

Q3. 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.

Code:-

int a=-2;
for(int i=0;i<n;i++)
{
  a=a+2;
  if(a%3==0)
    sum+=a;
}

System.out.print(sum);

Q4. 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 = 13+53+33, 370, 371, 407, etc.

Code:-

int num=n;
while(num>0)
{
  int r=num%10;
  result+=r*r*r;
  num/=10;
}

if (result==n)
  System.out.print(1);
else
  System.out.print(0);

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

Code:-

int sum=0,max=0;
for(int i1=0;i1<arr.length;i1++)
{
  if(arr[i1]>max)
    max=arr[i1];
  sum+=arr[i1];
}
mark_avg=sum/arr.length;
System.out.println(max);
System.out.print(mark_avg);

Disclaimer:- We do not claim 100% surety of solutions, these solutions are based on our sole expertise, and by using posting these answers we are simply looking to help students as a reference, so we urge do your assignment on your own.

For More NPTEL Answers:- CLICK HERE

Join Our Telegram:- CLICK HERE

Programming In Java Assignment 1 Answers 2022:- All the Answers provided here to help the students as a reference, You must submit your assignment at your own knowledge

If you found this article Interesting and helpful, don’t forget to share it with your friends to get this information.

Leave a Comment