0% found this document useful (0 votes)
21 views3 pages

CL 9 Comp Proj Part I

Uploaded by

faran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views3 pages

CL 9 Comp Proj Part I

Uploaded by

faran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Programs using Assignment statements.

1. Program to assign and display name, school name and city.


public class main biodata
{
public static void main(String args[])
{
String name=”Noor Zafar”;
String sch=”Loyola High School”;
String cty=”Kolkata”;
System.out.println(“Name of the student “+name);
System.out.println(“Name of the school “+sch);
System.out.println(“Name of the city “+cty);
}
}
Variables descriptions:
Variables Data Types Descriptions
name String Student name
sch String School name
cty String City name
2. Program to find the area and perimeter of a rectangle.
public class rectangle
{
public static void main(String args[])
{
int l=32;
int b=10;
int ar=0;
int p=0;
ar=(l*b);
p=2*(l+b);
System.out.println("The area of rectangle="+ar);
System.out.println("The perimeter of rectangle="+p);
}
}
Variables descriptions:
Variables Data Types Descriptions
l int length given
b int breadth given
ar int area of a rectangle
p int perimeter of a rectangle
3. Program to find the volume of a cuboid.
public class volume
{
public static void main()
{
int l=25;
int b=12;
int h=9;
int vol=l*b*h;
System.out.println(" Volume of a cuboid= "+ vol);
}
}
Variables descriptions:
Variables Data Types Descriptions
l int length given
b int breadth given
h int height given
vol int volume of cuboid
4. Program that converts Celsius to Fahrenheit.
public class conversiontemp
{
public static void main()
{
float cel;
float fah=0;
cel=23;
fah=((cel*9)/5);
System.out.println("Temperature in Fahrenheit= "+fah);
}
}
Variables descriptions:
Variables Data Types Descriptions
cel float Celsius given
fah float Fahrenheit as output
5. Program to display the numbers,95 and 45 after swapping.
public class swap
{
public static void main(String args[])
{
int a=95;
int b=45;
int c=0;

c=a;
a=b;
b=c;
System.out.println("The value of a="+a);
System.out.println("The value of b="+b);
}
}
Variables descriptions:
Variables Data Types Descriptions
a int 95
b int 45
c int 0 (swap)

You might also like