-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst.java
More file actions
49 lines (44 loc) · 1.46 KB
/
first.java
File metadata and controls
49 lines (44 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.*;
public class first {
public static void main(String args[]){
//Sum of two numbers
int num1 = 5;
int num2 = 7;
int sum = num1 + num2;
System.out.println("Sum of two numbers is: " + sum);
//Average of 3 numbers
Scanner sc = new Scanner(System.in);
System.out.println("Enter three numbers: ");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int avg = (a + b + c) / 3;
System.out.println("Average of three numbers is: " + avg);
//Area of a square
System.out.println("Enter the side of the square: ");
int side = sc.nextInt();
int area = side * side;
System.out.println("Area of square is:" + area);
//Stationary bill
System.out.println("Enter cost of the pencil: ");
float pencil = sc.nextFloat();
System.out.println("Enter cost of the pen: ");
float pen = sc.nextFloat();
System.out.println("Enter cost of the eraser: ");
float eraser = sc.nextFloat();
float totalCost = pencil + pen + eraser;
float gst = totalCost * 0.18f;
float totalwithgst = totalCost + gst;
System.out.println("Total cost without GST:"+ totalCost);
System.out.println("Total cost with GST:"+ totalwithgst);
//Expression
byte x = 4;
char y = 'a';
short s = 512;
int i = 1000;
float f = 3.14f;
double d = 99.9954;
double result = (f * b) + (i % c) - (d * s);
System.out.println("Result of expression is:"+ result);
}
}