-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathW3Ex_DataTypes.java
More file actions
177 lines (133 loc) · 5.09 KB
/
W3Ex_DataTypes.java
File metadata and controls
177 lines (133 loc) · 5.09 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package com.company;
import javax.swing.plaf.synth.SynthOptionPaneUI;
import java.util.Scanner;
public class W3Ex_DataTypes {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 1.
/*
System.out.println("Enter Fahrenheit value to get the celsius value");
double f = sc.nextDouble();
System.out.println("Celsius value is: ");
double l = ( f - 32 ) * ( 5 / 9f );
System.out.println(l);
*/
// 2.
/*
System.out.println("Enter Inch value to get Meter value");
double i = sc.nextDouble();
System.out.println("Meter value is: ");
double m = i/39.37f;
System.out.println(m);
*/
// 3.
/*
System.out.println("Input the integer between 0 to 999");
int i = sc.nextInt();
int firstdigit = i % 10;
int remainingone = i / 10;
int seconddigit = remainingone % 10;
int thirddigit = remainingone / 10;
System.out.println("Here is the sum of the digits: ");
int sum = firstdigit + seconddigit + thirddigit;
System.out.println(sum);
*/
// 4.
/*
System.out.println("Enter the minute value to get the days and year");
int i = sc.nextInt();
int year = i / 525600;
int remaining = i - year;
int days = (remaining / 1440) % 365;
System.out.println(i + " Minutes is approx " + year + " Years and " + days + " Days");
*/
// 5.
// 6.
/*
System.out.println("Enter your height in meters");
float height = sc.nextFloat();
System.out.println("Enter your weight in kg");
float weight = sc.nextFloat();
float bmi = weight / (height*height);
System.out.println("Your BMI is: " + bmi);
*/
// 7.
/*
System.out.println("Enter distance in meters");
int dist = sc.nextInt();
System.out.println("Enter hours");
int hour = sc.nextInt();
System.out.println("Enter minutes");
int min = sc.nextInt();
System.out.println("Enter seconds");
int sec = sc.nextInt();
System.out.println("Your speed in distance per second is: ");
double distpersec = (double) dist / (double) ((hour*3600) + (min * 60) + sec);
System.out.println(distpersec);
System.out.println("Your speed in kilometer per hour is: ");
double distkmperhour = (double) (dist / 1000) / (double) (hour + (min / 60) + (sec / 3600));
System.out.println(distkmperhour);
System.out.println("Your speed in miles per hour is: ");
double distmileperhour = (double) (dist / 1609) / (double) (hour + (min / 60) + (sec / 3600));
System.out.println(distmileperhour);
*/
// 8.
/*
System.out.println("Enter the number to get the square root, cube root, and fourth power");
double input = sc.nextInt();
double sqroot = (input*input);
double curoot = (input*input*input);
double forthpower = (input*input*input*input);
System.out.println("Square root is: " + sqroot);
System.out.println("Cube root is: " + curoot);
System.out.println("Forth Power is: " + forthpower);
*/
// 9.
/*
System.out.println("Input first integer");
double one = sc.nextDouble();
System.out.println("Input second integer");
double two = sc.nextDouble();
double sum = one + two;
System.out.println("Sum is: " + sum);
double sub = one - two;
System.out.println("Difference between is: " + sub);
double mul = one * two;
System.out.println("Product is: " + mul);
double div = one / two;
System.out.println("Division is: " + div);
double avg = (one + two) / 2;
if (one>two) {
System.out.println("Max integer is: " + one);
System.out.println("Min integer is: " +two);
}
else if (one<two) {
System.out.println("Max integer is: " + two);
System.out.println("Min integer is: " + one);
}
*/
// 10.
/*
System.out.println("Enter 6 Non-Negative number");
int n = sc.nextInt();
int one = n / 100000 % 10;
int two = n / 10000 % 10;
int three = n / 1000 % 10;
int four = n / 100 % 10;
int five = n / 10 % 10;
int six = n % 10;
System.out.println(one + " " + two + " " + three + " " + four + " " + five + " " + six);
*/
// 12.
/*
int n1 = Integer.MAX_VALUE;
int n2 = Integer.MIN_VALUE;
System.out.println("Signed Integers: " + n1 + ", " + n2);
System.out.println("-------------------------------------");
int compareSigned = Integer.compare(n1, n2);
System.out.println("Result of Signed Integer is: " + compareSigned);
int compareUnsigned = Integer.compareUnsigned(n1, n2);
System.out.println("Result of Unsigned Integer is: " + compareUnsigned);
*/
}
}