Repository navigation
Expand file tree
/
Copy pathHome1.java
More file actions
110 lines (91 loc) · 2.59 KB
/
Copy pathHome1.java
File metadata and controls
110 lines (91 loc) · 2.59 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
package Day9;
import java.util.Scanner;
public class Home1 {
//TODO Task
// 1. Write program that gets two inputs from user then prints sum
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Value 1:");
int number = scanner.nextInt();
System.out.println("Value 2:");
// 2. Write simple calculator,
// a. reads first input
// b. reads operator (+, -, *, /)
// c. reads second input
// d. prints result
System.out.println("::::::::::::::::::::::::::::::::::::::::::::::::");
int number2 = scanner.nextInt();
int sum = number + number2;
System.out.println("Total is your" + sum);
System.out.println("::::::::::::::::::::::::::::::::::::::::::::");
// 3. Write program that calculates from string:
// ex: one plus nine => 10, four subtract 2 => 2
Scanner in = new Scanner(System.in);
System.out.print("Input a number(string): ");
String str1 = in.nextLine();
int result = Integer.parseInt(str1);
System.out.printf("integer value:",result);
System.out.printf("\n");
}
}
// public class Test {
// public static void main(String[] args)
// {
// for (;;)
// System.out.println("TECHNO");
// }
// }
////Options:
////4.TECHNO (Infinitely)
// class Test {
// public
// static void main(String[] args)
// {
// for (int i = 0; i < 3)
// System.out.println("TECHNO");
// }
// }
////Options:
////2.Compile time error
// class Test {
// public static void main(String[] args)
// {
// boolean b = true;
// if (b = false) {
// System.out.println("HELLO");
// } else {
// System.out.println("BYE");
// }
// }
// }
////Option:
////4.BYE
//
// public class Test {
// public
// static void main(String[] args)
// {
// int a = 10, b = 20;
// if (a < b) {
// if (a > b) {
// System.out.println("HELLO TECHNO");
// } else {
// System.out.println("WELCOME");
// }
// }
// }
// }
////Option:
////2.WELCOME
//
// class Test {
// public static void main(String[] args)
// {
// for (int i = 0;; i++) {
// System.out.println("HIII");
// }
// System.out.println("BYE");
// }
// }
////Options:
////4. Compile time error