python and DBMS
python and DBMS
Section ECSc-1
1. To learn writing, executing and debugging programs related to basic I/O functions.
2. To learn writing, executing and debugging programs related to arithmetic operators.
Programming Language used:
Java
SOL:-
class Prog1{
public static void main(String args[])
{
System.out.println("Name: Sanjay Patel");
System.out.println("Roll: 2230041");
System.out.println("Branch: ECSc");
System.out.println("Department: Electronics");
System.out.println("University: KIIT University");
}}
2. Write a Java program to find the area and circumference of a circle, given
its radius, r.
SOL:
class Prog2{
public static void main(String args[])
{
System.out.println("Name: Sanjay Patel");
System.out.println("Roll: 2230041");
int r=3;
float area=3.14f*r*r;
float circumference=2*3.14f*r;
System.out.println("Area of the circle:"+area);
System.out.println("Circumference of the circle:"+circumference);
}}
3. Write a Java program to accept the length and breadth of a rectangle and
display its area and perimeter.
SOL:
class Prog3{
public static void main(String args[])
{
System.out.println("Name: Sanjay Patel");
System.out.println("Roll: 2230041");
int l=12, b=10;
float area=l*b;
float perimeter=2*(l+b);
System.out.println("Area of the rectangle:"+area);
System.out.println("Perimeter of the rectangle:"+perimeter);
}}
4. Write a Java program to accept the number of seconds and display its
equivalent number of hours, number of minutes and number of seconds (Hint:
Use / and % operators).
SOL:
import java.util.Scanner;
class Prog4{
public static void main(String args[])
{
System.out.println("Name: Sanjay Patel");
System.out.println("Roll: 2230041");
System.out.println("Enter Seconds");
Scanner sc= new Scanner(System.in);
int seconds=sc.nextInt();
int hours=seconds/3600;
int minutes=(seconds%3600)/60;
int sec=(seconds%3600)%60;
System.out.println("TIME="+hours+"h:"+minutes+"min:"+sec+"sec");
}}
Output:
OUTPUT 1:-
OUTPUT 2:-
OUTPUT 3:-
OUTPUT 4:-
Conclusion:
Learned to develop and execute basic Java programs .
_________________
Faculty Signature
Experiment Number WEEK 1 LAB 2
Section ECSc-1
SOL:
import java.lang.Math;
class Prog1{
public static void main(String args[])
{
System.out.println("Name: Sanjay Patel");
System.out.println("Roll: 2230041");
double x,y;
for(x=0;x<=1;x=x+0.1){
y=Math.exp(-x);
x=Math.floor(x*100)/100;
y=Math.floor(y*1000)/1000;
System.out.println("If X= "+x+" then Y= "+y);
}}}
2. Write a Java program to find the largest of three numbers using a conditional operator.
SOL:
import java.util.Scanner;
class Prog2{
public static void main(String args[])
{
System.out.println("Name: Sanjay Patel");
System.out.println("Roll: 2230041");
System.out.println("Enter three numbers");
Scanner sc= new Scanner(System.in);
int first =sc.nextInt();
int second =sc.nextInt();
int third=sc.nextInt();
int largest=(first>second)?(first>third?first:third):(second>third?second:third);
System.out.println("Largest Number is "+largest);
}}
3. Write a Java program to accept a point (x, y) and find whether it lies on the circle or
inside the circle or outside the circle. The center of the circle is (0, 0) and the radius of the
circle is 5. Equation of a circle with (0, 0) as the center and r as the radius is given by x2 +
y2 = r2.
1. If x2 + y2 < r2, then the point (x, y) lies within the circle.
2. If x2 + y2 > r2, then the point (x, y) lies outside the circle.
3. If x2 + y2 = r2, then the point (x, y) lies on the circle.
SOL:
import java.util.Scanner;
class Prog3{
public static void main(String args[])
{
System.out.println("Name: Sanjay Patel");
System.out.println("Roll: 2230041");
System.out.println("Enter Coordinates of the point");
Scanner sc= new Scanner(System.in);
int r=5;
int x =sc.nextInt();
int y =sc.nextInt();
if((x*x)+(y*y)>(r*r)){
System.out.println("point (x, y) lies within the circle ");}
else if((x*x)+(y*y)<(r*r)){
System.out.println("point (x, y) lies outside the circle.");}
else{
System.out.println("point (x, y) lies on the circle.");}
}}
SOL:
import java.util.Scanner;
import java.lang.Math;
class Prog4{
public static void main(String args[])
{
System.out.println("Name: Sanjay Patel");
System.out.println("Roll: 2230041");
System.out.println("Enter the Number");
Scanner sc= new Scanner(System.in);
int num =sc.nextInt();
int a,x,count=0;
double sum=0;
x=num;
while(num!=0){
count=count+1;
num=num/10;}
num=x;
for(int i=0;i<count;i++){
a=num%10;
sum=sum+Math.pow(a,count);
num=num/10;}
if(x==sum){
System.out.println("Number is armstrong number");}
else{
System.out.println("Number is not armstrong number");}
}}
OUTPUT 2:
OUTPUT 3:
OUTPUT 4:-
OUTPUT 5:-
Conclusion:
Learned to develop and execute Java programs using operators, if-else, for loop, etc.
_________________
Faculty Signature