-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode 12.txt
153 lines (75 loc) · 2.73 KB
/
code 12.txt
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
/*
Program: Using Methods
Programmer: J.Sookha
Description: using a method with a parameter
passing a value to a procedure from the main method
*/
package usingmethods;
import java.util.Scanner;
public class UsingMethods{
static int intNumber; // take note of the variable declared here ... and how it is used
public static void main (String[] args)
{
int intNum2;
Read(intNum2); // passing a parameter value
Print();
System.out.println(intNum2);
}
// parameters are variables declared at the point of declaring a method
// they are variables that are only to be used inside a method
public static void Read(int intN2)
{
Scanner sc = new Scanner(System.in);
System.out.print("Please enter a number ");
intNumber = sc.nextInt();
System.out.print("Please enter Num2 ");
intN2 = sc.nextInt();
}
public static void Print(){
System.out.println(intNumber);
// intN2 = 5; // just putting this here
}
}
package GradePerc;
import java.util.Scanner;
import java.lang.*;
public class GradePerc{
public static void main(String[] args){
int intH1, intH2, intH3, intH4, intH5;
int intT1, intT2, intT3, intT4;
int intSum, intSumH, intSumT;
int intMinH, intMinT;
double dblPerc;
//Scanner - read in all your values
Scanner sc = new Scanner(System.in);
System.out.print("Enter the mark for Homework1: ");
intH1 = sc.nextInt();
System.out.print("Enter the mark for Homework2: ");
intH2 = sc.nextInt();
System.out.print("Enter the mark for Homework3: ");
intH3 = sc.nextInt();
System.out.print("Enter the mark for Homework4: ");
intH4 = sc.nextInt();
System.out.print("Enter the mark for Homework5: ");
intH5 = sc.nextInt();
System.out.print("Enter the mark for Test1: ");
intT1 = sc.nextInt();
System.out.print("Enter the mark for Test2: ");
intT2 = sc.nextInt();
System.out.print("Enter the mark for Test3: ");
intT3 = sc.nextInt();
System.out.print("Enter the mark for Test4: ");
intT4 = sc.nextInt();
//****************************************************
intSumH = intH1 + intH2 + intH3 + intH4 + intH5;
intSumT = intT1 + intT2 + intT3 + intT4;
intMinH = Math.min(Math.min(intH5, Math.min(intH4, Math.min(intH3, intH2)), intH1);
intSumH = intSumH - intMinH;
intMinT = Math.min(Math.min(intT4, Math.min(intT3, intT2),intT1);
intSumT = intSumT - intMinT;
dblPerc = ((intSumH + intSumT)/ 500) * 100;
//Print out your answer
System.out.println();
System.out.println("The percentage the student received is " + dblPerc + "%");
}
}