Programming in JAVA.
Java Week 1: 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 ".
PROGRAM:
if(radius<=0)
{
System.out.print("please enter non zero positive number");
}
else
{
perimeter= 2 * Math.PI * radius;
area= Math.PI * radius *radius;
System.out.println(perimeter);
System.out.print(area);
}
Java Week 1: 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.
PROGRAM:
if(x>y && x>z)
{
System.out.print(x);
}
else if(y>x && y>z)
{
System.out.print(y);
}
else
{
System.out.print(z);
}
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100% correct solutions.
No comments:
Post a Comment
If you have any problems related to solutions or any concept please let me know.