-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHelloMaster.java
More file actions
182 lines (141 loc) · 3.7 KB
/
Copy pathHelloMaster.java
File metadata and controls
182 lines (141 loc) · 3.7 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
178
179
180
181
182
import java.util.Scanner;
import javax.swing.plaf.synth.SynthSeparatorUI;
class HelloMaster
{
public static void main(String [] args)
{
Scanner input = new Scanner(System.in);
/*
Control Structure
1. Sequence
1. Selection
2. Repetition
//Selection
if,if-else, if-else if-else,switch
*/
/* int marks=55;
if(marks>=85)
System.out.println("A");
else if(marks>=70)
System.out.println("B+");
else if(marks>=60)
System.out.println("B");
else if(marks>=50)
System.out.println("C");
else
System.out.println("F"); */
/* int number= input.nextInt();
switch(number){ //expression
case 1:
System.out.println("Monday");
System.out.println("Blue Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
case 4:
System.out.println("Thursday");
break;
default:
System.out.println("Weekend");
break;
}
*/
/*int a=14,b=5,c=8;
if(a>b)
{
if(a>c)
System.out.println(a+" is maximum");
else
System.out.println(c+" is maximum");
}
else
{
if(b>c)
System.out.println(b+ " is maximum");
else
System.out.println(c+ " is maximum");
}
output
print(),println(),printf()
input
Scanner,BufferedReader,ConsoleReader
*/
//int nextInt()
//float nextFloat()
//double nextDouble()
//String nextLine()
/* System.out.println("How old are you? ");
int age;
age=input.nextInt();
System.out.println("I am " +age+" years old");
input.nextLine();
System.out.println("What is ur name? ");
String name=input.nextLine();
System.out.println("My name is: "+name); */
//Repetition, loops
/*
while loop, do while and for loop
syntax
initial value
while(condition){ //pre-test loop
statements
}
do {
statements
}while(condition); //post-test loop
*/
/*int x=10;
while(x<=1)
{
System.out.println(x);
x++;
}*/
/*int y = 10;
do {
System.out.println(y);
y++;
}while(y<=1);*/
//for loop; initial value; final value;step value
// for(initial value;final value;step value){}
/*for(int i=1;i<=10;i++){
System.out.println(i);
}*/
// foreach loop
/*
return type functionName([parameters])
{
}
return type-> int, float, double,String,boolean,
non-return -> void
*/
//System.out.println(sumThree(3,4,5));
//multiply(4, 5);
/* int x=7;
System.out.println(x); */
int[] a = {1,2,4,6,8,10,9};
/* System.out.println(a[0]);
System.out.println(a[4]);
System.out.println(a[6]); */
for(int i=0;i<=6;i++)
{
System.out.println(a[i]);
}
}
//function definition
/* static int sumTwo(int a,int b)
{
return a+b;
}
static int sumThree(int x,int y, int p)
{
return sumTwo(x,y)+p;
}
static void multiply(int a,int b)
{
System.out.println(a*b);
} */
}