Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 169e64c

Browse files
committed
varibles, data types
1 parent 2407018 commit 169e64c

File tree

6 files changed

+85
-4
lines changed

6 files changed

+85
-4
lines changed

src/Animal.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,15 @@ public class Animal {
2020
Animal(String name, float weight) {
2121
this.name = name;
2222
this.weight = weight;
23-
2423
}
2524

2625
Animal(String name) {
2726
this.name = name;
28-
2927
}
3028

3129
Animal(String size, String name) {
3230
this.size = size;
3331
this.name = name;
34-
3532
}
3633

3734
//copy constructor
@@ -40,6 +37,5 @@ public class Animal {
4037
this.weight = animal.weight;
4138
this.size = animal.size;
4239
}
43-
4440
}
4541

src/binod/AreaSquare.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package binod;
2+
import java.util.Scanner;
3+
public class AreaSquare {
4+
public static void main(String[] args) {
5+
Scanner scanner=new Scanner(System.in);
6+
System.out.println("Enter side of a square");
7+
double side=scanner.nextDouble();
8+
double area=side*side;
9+
System.out.println("The area of square is: "+area);
10+
}
11+
}

src/binod/Average3Numbers.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package binod;
2+
import java.util.Scanner;
3+
public class Average3Numbers {
4+
public static void main(String[] args) {
5+
Scanner scanner=new Scanner(System.in);
6+
System.out.println("Input First Number:");
7+
int firstNumber=scanner.nextInt();
8+
System.out.println("Input Second Number:");
9+
int secondNumber=scanner.nextInt();
10+
System.out.println("Input Third Number:");
11+
int thirdNumber=scanner.nextInt();
12+
13+
int average=(firstNumber+secondNumber+thirdNumber)/3;
14+
System.out.println("The average of three numbers is: "+average);
15+
}
16+
}

src/binod/Pattern1.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package binod;
2+
public class Pattern1 {
3+
public static void main(String[] args) {
4+
for(int i=4;i>0;i--){
5+
for(int j=0;j<i;j++){
6+
System.out.print("*");
7+
}
8+
System.out.println();
9+
}
10+
}
11+
}

src/binod/PrintBill.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package binod;
2+
import java.util.Scanner;
3+
public class PrintBill {
4+
public static void main(String[] args) {
5+
Scanner scanner = new Scanner(System.in);
6+
System.out.println("Enter cost of pencil:");
7+
float costOfPencil = scanner.nextFloat();
8+
System.out.println("Enter cost of pen");
9+
float costOfPen = scanner.nextFloat();
10+
System.out.println("Enter cost of eraser");
11+
float costOfEraser = scanner.nextFloat();
12+
final float taxRate = 0.18f;
13+
float totalCostWithoutTax = costOfPencil + costOfPen + costOfEraser;
14+
float taxForPencil = taxRate * costOfPencil;
15+
float taxForPen = taxRate * costOfPen;
16+
float taxForEraser = taxRate * costOfEraser;
17+
float totalTax = taxForPencil + taxForPen + taxForEraser;
18+
float costOfPencilWithTax = costOfPencil + taxForPencil;
19+
float costOfPenWithTax = costOfPen + taxForPen;
20+
float costOfEraserWithTax = costOfEraser + taxForEraser;
21+
float totalCostWithTax = costOfPencilWithTax + costOfPenWithTax + costOfEraserWithTax;
22+
System.out.println("Item\tCost\tTax\tPrice");
23+
System.out.println("----------------------------------");
24+
System.out.println("Pencil\t" + costOfPencil + "\t" + taxForPencil + "\t" + costOfPencilWithTax);
25+
System.out.println("Pen\t" + costOfPen + "\t" + taxForPen + "\t" + costOfPenWithTax);
26+
System.out.println("Eraser\t" + costOfEraser + "\t" + taxForEraser + "\t" + costOfEraserWithTax);
27+
System.out.println("----------------------------------");
28+
System.out.println("Total\t" + totalCostWithoutTax + "\t" + totalTax + "\t" + totalCostWithTax);
29+
}
30+
}

src/binod/TypeOfResult.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package binod;
2+
public class TypeOfResult {
3+
public static void main(String[] args) {
4+
byte b=4;
5+
int c=97;
6+
short s=512;
7+
int i=1000;
8+
float f=3.14f;
9+
double d=99.9954;
10+
11+
int $=24;
12+
13+
double result=(f*b)+(i%c)-(d*s)+$;
14+
System.out.println(result);
15+
}
16+
17+
}

0 commit comments

Comments
 (0)