-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOPMorning1Week2_1.java
More file actions
128 lines (101 loc) · 3.01 KB
/
OOPMorning1Week2_1.java
File metadata and controls
128 lines (101 loc) · 3.01 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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("please enter an int value");
int number1 = scanner.nextInt();
System.out.println(number1);
int number2 = scanner.nextInt();
System.out.println(number2);
System.out.println("sum: "+ (number1 + number2));
//TestMethod();
// String[] studNames = {"asdasd","asdas"};
// float[] midScores = {15,20,30,90,85,45,65};
// float[] finScores = {90,50,78,98,63,45,50};
// float[] averScores = new float[7];
//
// for (int i = 0; i<7;i++){
// averScores[i] = getScore(midScores[i],finScores[i] );
// System.out.println(averScores[i]);
// }
}
private static void TestMethod() {
System.out.println("Hello world!");
Student s1 = new Student();
s1.name= "asdasd";
s1.mid =75;
s1.fin =80;
System.out.println(s1.getScore());
Student s2 = new Student();
s2.name = "asdsadsa";
s2.mid = 95;
s2.fin = 90;
System.out.println(s2.getScore());
}
static float getScore(float mid, float fin){
return mid *.4f + fin *.6f;
}
// static void test(){
// //ifCondition(50, 45);
// //switchCase('B');
//
// // forLoop(20);
// //forEachLoop();
//
// // whileLoop(20);
// // doWhileLoop(20);
//
// }
static void doWhileLoop(int limit){
int input = 0;
do{
if (input % 2 == 0)
System.out.println(input +" is even");
else
System.out.println(input +" is odd");
input++;
}
while (input < limit);
}
static void whileLoop(int limit) {
int x = 0;
while ( x < limit){
x+=1;
}
System.out.println(x);
}
static void forEachLoop(){
int[] numbers = new int[]{1,56,78,23,45};
for(int number : numbers)
System.out.println(number);
}
static void forLoop(int maxVal){
int result =0;
for (int i = 0; i<=maxVal; i++)
result +=i;
System.out.println(result);
}
static void switchCase(char scoreCharacter){
switch (scoreCharacter){
case 'A':
System.out.println("perfect");
break;
case 'B':
System.out.println("not bad");
break;
case 'C':
System.out.println("need to study more");
break;
default:
System.out.println("unknown");
break;
}
}
static void ifCondition(float mid, float fin){
float average = mid *.4f + fin *.6f;
if (average < 35) System.out.println("failed");
else if(average < 50) System.out.println("conditionally passed");
else
System.out.println("passed");
}
}