Skip to content

Commit 2327eac

Browse files
authored
Add files via upload
1 parent ea8168b commit 2327eac

13 files changed

+105
-0
lines changed

CalculateArea.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//#include<stdio.h> - printf is in standard input output header file
2+
import java.util.Scanner;//utilities
3+
class CalculateArea{
4+
public static void main(String args[]){
5+
double radius;//floating type values
6+
double area;
7+
//read input from user
8+
Scanner scan=new Scanner(System.in);
9+
radius=scan.nextDouble();
10+
area=Math.PI * radius * radius;
11+
//append radius with the string "Area is"
12+
System.out.println("Area is"+area);
13+
//System.out object to print(output) something
14+
}
15+
}

Chapter 3.rar

23.5 KB
Binary file not shown.

Chapter 4.rar

21.4 KB
Binary file not shown.

Chapter 5.rar

25.2 KB
Binary file not shown.

Chapter 6.rar

33.7 KB
Binary file not shown.

Chapter7.rar

36.8 KB
Binary file not shown.

CommandInputDemo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class CommandInputDemo{
2+
//args is command line arguments which are passed to the program before the program starts executing
3+
public static void main(String args[]){
4+
//index -0
5+
System.out.println("Welcome "+args[0]);//Name
6+
System.out.println("From "+args[1]);//class
7+
System.out.println("In "+args[2]);//School Name
8+
}
9+
}

IncrementDecrementDemo.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class IncrementDecrementDemo{
2+
public static void main(String a[]){
3+
int i=5;
4+
int j=6;
5+
int k=i++;//6
6+
//1. Use the value
7+
//2. Change the value
8+
System.out.println(k);//6
9+
k=++j;//pre increment 7
10+
//1. Change the value
11+
//2. Use the value
12+
System.out.println(k);//7
13+
//7+6
14+
System.out.println(++i+--j);//13
15+
}
16+
}

MathDemo.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.lang.*;//import all classes from package java.lang
2+
import java.util.Scanner;
3+
class MathDemo{
4+
public static void main(String agrs[]){
5+
int a=10;
6+
int b=4;
7+
//Print 10 raised to a power of 4
8+
System.out.println(Math.pow(a,b));//10*10*10*10
9+
System.out.println(Math.pow(b,a));//4^10
10+
//Math is in package java.lang
11+
//Scanner is in package java.util
12+
//java.lang package is imported by default in all your programs
13+
float f=10.5f;
14+
float fl=10.6F;
15+
int x=10;
16+
int y=20;
17+
x+=30; //x=x+30;
18+
y/=5; //y=y/5;
19+
System.out.println(x);
20+
System.out.println(y);
21+
22+
23+
}
24+
}

OpDemo.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class OpDemo{
2+
public static void main(String args[]){
3+
int a=10;
4+
int b=20;
5+
System.out.println("Addition "+(a+b));//java will append them
6+
System.out.println("Subtraction "+(a-b));
7+
System.out.println("Multiplication "+(a*b));
8+
System.out.println("Division "+(a/b));//0
9+
//Type casting- cast an integer to a float
10+
//treat b as a float value
11+
System.out.println("Division "+(a/(float)b));//0.5
12+
//Modulus- Remainder
13+
System.out.println("Modulus "+(20%13));//7
14+
System.out.println("Divide "+(20/13));//7
15+
}
16+
}

0 commit comments

Comments
 (0)