forked from cs-dept-ibbul/java2019
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab3.java
More file actions
64 lines (60 loc) · 2.22 KB
/
Copy pathLab3.java
File metadata and controls
64 lines (60 loc) · 2.22 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* Write a description of class Lab3 here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
public class Lab3
{
public static void main(String[]arg){
System.out.println("\nEXERCISES 01 Volume&Surface-area");
Scanner scann = new Scanner(System.in);
System.out.println("Enter the length:");
double l = scann.nextDouble();
System.out.println("Enter the width:");
double w = scann.nextDouble();
System.out.println("Enter the heigth:");
double h = scann.nextDouble();
double volume = (h*w*l);
double surface = 2*(l*w+l*h+w*h);
System.out.println("The volume of the box: "+volume);
System.out.println("The surface area of the box: "+surface);
System.out.println("\nEXERCISES 02 USERNAME&DOMAIN");
Scanner scan = new Scanner(System.in);
String domain,username;
System.out.println("Please enter a valid email address");
String email = scan.nextLine();
username = email.split("@")[0];
domain = email.substring(email.indexOf("@")+1);
//username = email.substring(email.indexOf("@")-1);
System.out.println("\nUsername:"+ username);
System.out.println("Domain:"+ domain);
System.out.println("\nEXERCISES 03 Perimeter&Area");
Scanner scan1 = new Scanner(System.in);
System.out.println("Enter the 1st sides:");
int a = scan1.nextInt();
System.out.println("Enter the 2nd sides:");
int b = scan1.nextInt();
System.out.println("Enter the 3rd sides:");
int c = scan1.nextInt();
double s =(a+b+c)/2;
double area = Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.println("The Perimeter of triangle is: "+s);
System.out.println("The area of the triangle with the input sides is "+ area+"unit square");
if(a>b && a>c){
System.out.println("The longest side is: "+a);
}else if(b>c){
System.out.println("The longest side is: "+b);
}else{
System.out.println("The longest side is: "+c);
}
if(a<b && a<c){
System.out.println("The smallest side is: "+a);
}else if(b<c){
System.out.println("The smallest side is: "+b);
}else{
System.out.println("The smallest side is: "+c);
}
}
}