FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs/student.java at main · VirajPatidar/Java-Programs · GitHub
VirajPatidar
/
Java-Programs
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programs
/
student.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (42 loc) · 1.34 KB
Breadcrumbs
Java-Programs
/
student.java
Copy path
File metadata and controls
42 lines (42 loc) · 1.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
java
.
util
.
Scanner
;
public
class
student
{
int
rollNo
;
int
total
,
p
,
c
,
m
;
double
percentage
;
String
Name
;
static
Scanner
sc
=
new
Scanner
(
System
.
in
);
student
(){
getInfo
();
total
=
p
+
c
+
m
;
calcPercentage
(
total
);
display
();
}
student
(
String
str
,
int
r
,
int
p
,
int
c
,
int
m
) {
rollNo
=
r
;
Name
=
str
;
total
=
p
+
c
+
m
;
calcPercentage
(
total
);
display
();
}
void
getInfo
(){
System
.
out
.
println
(
"Enter student roll number, Name, and PCM Marks in order"
);
rollNo
=
Integer
.
parseInt
(
sc
.
nextLine
());
Name
=
sc
.
nextLine
();
p
=
Integer
.
parseInt
(
sc
.
nextLine
());
c
=
Integer
.
parseInt
(
sc
.
nextLine
());
m
=
Integer
.
parseInt
(
sc
.
nextLine
());
}
void
calcPercentage
(
int
totalMarks
){
percentage
= (
double
)
totalMarks
/
300
*
100
;
}
void
display
(){
System
.
out
.
println
(
"------------------------"
);
System
.
out
.
println
(
"Name: "
+
Name
+
"
\n
Roll Number: "
+
rollNo
+
"
\n
TotalMarks: "
+
total
+
"
\n
Percentage score: "
+
percentage
);
System
.
out
.
println
(
"------------------------"
);
}
public
static
void
main
(
String
[]
args
) {
student
s1
=
new
student
();
System
.
out
.
println
(
"
\n
Using parameterized constuctor"
);
student
s2
=
new
student
(
"Ram"
,
191001
,
93
,
85
,
74
);
sc
.
close
();
}
}
Back
|
FazBrowse Home
|
New Git URL