Aztecant Assignment
HW2/StudentRecordProject.java
HW2/StudentRecordProject.java
/**
* Filename = StudentRecordProject.java
* Author = Abboss Daneshpour
* Date = July 08,2018
* The purpose of this program is to store the quiz record of a student according to the Student EMPLID.
* As well as this program stores the age in months and years
* It also stores the current temperature in Celsius as well as in Fahrenheit.
*/
package
studentrecordproject
;
import
java
.
util
.
Scanner
;
public
class
StudentRecordProject
{
public
static
void
main
(
String
[]
args
)
{
//Declare constant symbol
final
String
DEGREE
=
"\u00b0"
;
//Declare and initialize variables to hold values
int
emplid
=
0
;
int
age
=
0
;
int
ageInYears
=
0
;
double
quiz1
=
0.0
;
double
quiz2
=
0.0
;
double
quiz3
=
0.0
;
double
averageQuizScore
=
0.0
;
double
temprature
=
0.0
;
double
tempratureFahrenheit
=
0.0
;
// The below statements will take input of EMPLID,quiz1 score, quiz2 score, quiz3 score
//age in months, temperature in Celsius respectively.
Scanner
scn
=
new
Scanner
(
System
.
in
);
// Prompt user to enter employee ID
System
.
out
.
print
(
"Enter your Student EMPLID (0 - 999999): "
);
//the nextInt() method scans the next int value
emplid
=
scn
.
nextInt
();
// Prompt user to enter quiz 1 score
System
.
out
.
print
(
"Enter your quiz1 percentage score (0.0 - 100.0): "
);
//the nextDouble() method scans the next double value
quiz1
=
scn
.
nextDouble
();
// Prompt user to enter quiz 2 score
System
.
out
.
print
(
"Enter your quiz2 percentage score (0.0 - 100.0): "
);
//the nextDouble() method scans the next double value
quiz2
=
scn
.
nextDouble
();
// Prompt user to enter quiz 3 score
System
.
out
.
print
(
"Enter your quiz3 percentage score (0.0 - 100.0): "
);
//the nextDouble() method scans the next double value
quiz3
=
scn
.
nextDouble
();
// Prompt user to enter age in months
System
.
out
.
print
(
"Enter your age in months (0-1440): "
);
//the nextInt() method scans the next int value
age
=
scn
.
nextInt
();
// Prompt user to enter degrees
System
.
out
.
print
(
"Enter the current Temperature in degrees Celsius: "
);
//the nextDouble() method scans the next int value
temprature
=
scn
.
nextDouble
();
//compute the age in years by dividing the number of months by 12 and store
//the output in ageInYears variable
ageInYears
=
age
/
12
;
//The variable averageQuizScore will store the average of quiz1,quiz2 and quiz3
//by adding up the 3 mentioned variables and then dividing them by 3.
averageQuizScore
=
(
quiz1
+
quiz2
+
quiz3
)
/
3
;
//round off averageQuizScore to 2 decimal places
averageQuizScore
=
Double
.
parseDouble
(
String
.
format
(
"%.1f"
,
averageQuizScore
));
//The variable temperatureFahrenheit will store the current Temperature in Fahrenheit
//by multiplying the Temperature in celsius with 1.8 and then adding 32 into it.
tempratureFahrenheit
=
temprature
*
(
1.8
)
+
32
;
//round off temperatureFahrenheit to 2 decimal places
tempratureFahrenheit
=
Double
.
parseDouble
(
String
.
format
(
"%.1f"
,
tempratureFahrenheit
));
//The below statements will output of EMPLID, quiz1 score, quiz2 score, quiz3 score
// Averge Score in Quiz,Age in months, Age in Fahrenheit, temperature in Celsius, Temperature in Fahrenheit.
System
.
out
.
println
(
"***Thank you***"
);
System
.
out
.
println
(
"Student EMPLID: "
+
emplid
);
System
.
out
.
println
(
"Quiz 1 Score: "
+
quiz1
);
System
.
out
.
println
(
"Quiz 2 Score: "
+
quiz2
);
System
.
out
.
println
(
"Quiz 3 Score: "
+
quiz3
);
System
.
out
.
println
(
"Average quiz score: "
+
averageQuizScore
);
System
.
out
.
println
(
"Age in months: "
+
age
);
System
.
out
.
println
(
"Age in years: "
+
ageInYears
);
System
.
out
.
println
(
"Temprature in Celsius: "
+
temprature
+
DEGREE
);
System
.
out
.
println
(
"Temprature in Fahrenheit: "
+
tempratureFahrenheit
+
DEGREE
);
}
}
HW2/HW_2_Test_Cases.pdf
Name: Abboss Daneshpour
Assignment: Week 2
Date: July 08, 2018
Title: Test Cases
Input Expected Output Actual Output Pass?
EMPLID: 32012 Quiz1: 30.0 Quiz2: 20.5 Quiz3: 60.2 Age in months: 120 Temperature in Celsius: 23.30
*** Thank you *** Student EMPLID: 32012 Quiz 1 Score: 30.0 Quiz 2 Score: 20.5 Quiz 3 Score: 60.2 Average quiz score: 36.9 Age in months: 120 Age in years: 10 Temperature in Celsius: 23.30
Temperature in Fahrenheit: 73.90
*** Thank you *** Student EMPLID: 32012 Quiz 1 Score: 30.0 Quiz 2 Score: 20.5 Quiz 3 Score: 60.2 Average quiz score: 36.9 Age in months: 120 Age in years: 10 Temperature in Celsius: 23.30
Temperature in Fahrenheit: 73.90
Yes
EMPLID: 3224 Quiz1: 74.6 Quiz2: 76.9 Quiz3: 99.9 Age in months: 400 Temperature in Celsius: 32.10
*** Thank you *** Student EMPLID: 3224 Quiz 1 Score: 74.6 Quiz 2 Score: 76.9 Quiz 3 Score: 99.9 Average quiz score: 83.8 Age in months: 400 Age in years: 33 Temperature in Celsius: 32.10
Temperature in Fahrenheit: 89.80
*** Thank you *** Student EMPLID: 3224 Quiz 1 Score: 74.6 Quiz 2 Score: 76.9 Quiz 3 Score: 99.9 Average quiz score: 83.8 Age in months: 400 Age in years: 33 Temperature in Celsius: 32.10
Temperature in Fahrenheit: 89.80
Yes
EMPLID: 332232 Quiz1: 92.8 Quiz2: 56.7 Quiz3: 66.9 Age in months: 345 Temperature in Celsius: 25.70
*** Thank you *** Student EMPLID: 332232 Quiz 1 Score: 92.8 Quiz 2 Score: 56.7 Quiz 3 Score: 66.9 Average quiz score: 72.1 Age in months: 345 Age in years: 28 Temperature in Celsius: 25.70
Temperature in Fahrenheit: 78.30
*** Thank you *** Student EMPLID: 332232 Quiz 1 Score: 92.8 Quiz 2 Score: 56.7 Quiz 3 Score: 66.9 Average quiz score: 72.1 Age in months: 345 Age in years: 28 Temperature in Celsius: 25.70
Temperature in Fahrenheit: 78.30
Yes