-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh01_04_Practice1.java
More file actions
42 lines (38 loc) · 1.67 KB
/
Ch01_04_Practice1.java
File metadata and controls
42 lines (38 loc) · 1.67 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
import java.util.Scanner;
public class Ch01_04_Practice1 {
public static void main(String[] args) {
//Simple input from user
System.out.print("Enter your name: ");
Scanner name = new Scanner(System.in);
String N = name.nextLine();
System.out.println("Hello, " + N + "! You're Welcome to the world of Programming!");
//Calculator
System.out.println("Welcome to 4 Operation Calculator");
Scanner arithmetic = new Scanner(System.in);
System.out.print("Enter the First Number: ");
float A = arithmetic.nextFloat();
System.out.print("Enter the Second Number: ");
float B = arithmetic.nextFloat();
System.out.print("Enter the Third Number: ");
float C = arithmetic.nextFloat();
float sum = A + B + C;
System.out.println("The Sum of the Numbers are: " + sum);
float difference = A - B - C;
System.out.println("The difference is: " + difference);
float multiplication = A*B*C;
System.out.println("The Product is: " + multiplication);
float division = (A/B)/C;
System.out.println("Division is as follows: "+ division);
//Area of Cuboid
System.out.println("Let's Calculate the Area of A Cuboid");
Scanner area = new Scanner(System.in);
System.out.print("Enter the length of the Cuboid: ");
float l = area.nextFloat();
System.out.print("Enter the Breadth of Cuboid: ");
float b = area.nextFloat();
System.out.print("Enter the Height of Cuboid: ");
float h = area.nextFloat();
float ar = l*b*h;
System.out.println("The Area of Cuboid is: "+ ar);
}
}