Assignment Operator
public class AssignemtOperator {
public static void main(String[] args) {
int a,b;
a=10;
b=5;
System.out.println(a);
System.out.println(b);
a+=b;
System.out.println(a);
System.out.println(b);
a+=b;
System.out.println(a);
System.out.println(b);
b+=a;
System.out.println(a);
System.out.println(b);
}
Subtraction and stuff
import java.util.Scanner;
public class CalculationSubtracting {
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
System.out.println("Input First Integer");
int a = scan.nextInt();
System.out.println("Input Second Integer");
int b = scan.nextInt();
System.out.printf("Sum of the two integers is = %d\n", a-b);
}
Perimeter and Area
public class PerimeterAndArea {
public static void main(String[] args) {
int h,w;
h=7;
w=5;
System.out.printf("Area of rectangle = %d\n",h*w);
System.out.printf("Perimeter of rectangle = %d\n",h+h*w+w);
}
MY op Marks
public class ProjectOf5Subjects {
public static void main(String[] args) {
float a,b,c,d,e,f,g,h;
h=80*5;
g=80;
a=72;
b=75;
c=78;
d=68;
e=72;
f=72+75+78+68+72;
System.out.printf("Total marks in Hindi= %f marks out of %f\n", a,g);
System.out.printf("Total marks in Science= %f marks out of %f\n", b,g);
System.out.printf("Total marks in Social Science= %f marks out of %f\n", c,g);
System.out.printf("Total marks in English= %f marks out of %f\n", d,g);
System.out.printf("Total marks in Maths= %f marks out of %f\n", e,g);
System.out.printf("Total marks in all Subjects= %f\n", a+b+c+d+e);
System.out.printf("Total Percentage of all Subjects= %f Percent\n",f/h*100);
}
Intro to Variables
public class Variables {
public static void main(String[] args) {
int x,y,z;
x=10;
y=11;
z=12;
System.out.printf("Addition of x and y is %d",x+y);
System.out.printf("\nSubtraction of x and y is %d",x-y);
System.out.printf("\nMultiplication of x and y is %d",x*y);
System.out.printf("\nDivision of x and y is %d\n",x/y);
}
}
Corona Temperature
public class Centigrade {
public static void main(String[] args) {
float a,b;
a=100;
b= a*9/5+32;
System.out.printf("Temperature in Fahrenheit is = %f\n",b);
}
Centemetre, Metre, Kilometre
public class Centimeter {
public static void main(String[] args) {
float c,m,k;
c=1000;
m= c/100;
k= m/1000;
System.out.printf("Length in metre = %f metre \n", m);
System.out.printf("Length in Kilometre = %f Kilometre \n", k);
}
Intro to Character
public class Character {
public static void main(String[] args) {
char a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;
a='r';
b='i';
c='s';
d='h';
e='u';
f='l';
g='h';
h='e';
i='l';
j='l';
k='o';
l='h';
m='e';
n='l';
o='l';
p='o';
System.out.printf("%c",a);
System.out.printf("%c", b);
System.out.printf("%c", c);
System.out.printf("%c", d);
System.out.printf("%c", e);
System.out.printf("%c\n", f);
System.out.printf(" %c\n",g);
System.out.printf(" %c\n",h);
System.out.printf(" %c\n",i);
System.out.printf("%c",l);
System.out.printf("%c", m);
System.out.printf("%c", n);
System.out.printf("%c", o);
System.out.printf("%c\n", p);
System.out.printf(" %c\n",j);
System.out.printf(" %c\n",k);
}
Stupid Decimal numbers
public class FloatNumbers {
public static void main(String[] args) {
float r;
r=6;
System.out.printf("Perimeter of the circle = %f inches\n",2*3.14*r);
System.out.printf("Area of circle = %f square inches\n",3.14*r*r);
}