PART B- Javascript
Using a text editor (VS Code or Notepad) and a web browser, you will demonstrate how to create an HTML file, externally link a JavaScript file, and write some source code in the JavaScript file.
a..Create two blank files to be an HTML file and a JavaScript file. The file names should be partA.html and partA.js.
b.. Create a basic HTML webpage structure.
c..Link the JavaScript file to the HTML file using the <script> tag.
d.. Prompt for a Student name and ask for 3 numeric grades (0 to 100)
Table :
<html> <head> <title>Average Grade</title> </head> <body> <p id="studentName"></p> <div>Grade: <input type="text" id="numGrade1" readonly><input type="text" id="letGrade1" readonly></div> <div>Grade: <input type="text" id="numGrade2" readonly><input type="text" id="letGrade2" readonly></div> <div>Grade: <input type="text" id="numGrade3" readonly><input type="text" id="letGrade3" readonly></div> <button>Get Letter Grade</button> </body> </html |
Assignment Data
% Range: |
Alpha Grades: |
> 94 |
A+ |
94 – 90 |
A |
89 – 85 |
A- |
84 – 80 |
B+ |
79 – 75 |
B |
74 – 70 |
B- |
69 – 65 |
C+ |
64 – 60 |
C |
59 – 50 |
D |
< 50 |
F |
PART B - Python
Using a text editor (VS Code or Jupyter Lab), you will demonstrate how to write some source code in Python. Translating your work from Part A, you will demonstrate your ability to comment your source code while exploring operators and output in Python.
partA.html
Editable code:
<html>
<head>
<title>Average Grade</title>
</head>
<body>
<p id="studentName"></p>
<div>Grade: <input type="text" id="numGrade1" readonly><input type="text" id="letGrade1" readonly></div>
<div>Grade: <input type="text" id="numGrade2" readonly><input type="text" id="letGrade2" readonly></div>
<div>Grade: <input type="text" id="numGrade3" readonly><input type="text" id="letGrade3" readonly></div>
<button onclick="get_letter_grades()">Get Letter Grade</button>
</body>
<script src="partA.js"></script>
</html
Images of the code (for indentation reference):
partA.js
Editable code:
var person = prompt("Enter your Name", "");
var num_grade1 = prompt("Enter your Numerical Grade 1 (0 to
100)", "");
var num_grade2 = prompt("Enter your Numerical Grade 2 (0 to 100)",
"");
var num_grade3 = prompt("Enter your Numerical Grade 3 (0 to 100)",
"");
if (person != null) {
document.getElementById("studentName").innerHTML =
person;
}
if (num_grade1 != null) {
document.getElementById("numGrade1").value =
num_grade1;
}
else{
num_grade1 = 0;
}
if (num_grade2 != null) {
document.getElementById("numGrade2").value =
num_grade2;
}
else{
num_grade2 = 0;
}
if (num_grade3 != null) {
document.getElementById("numGrade3").value =
num_grade3;
}
else{
num_grade3 = 0;
}
function get_letter_grades() {
if (num_grade1 > 94){
document.getElementById("letGrade1").value = "A+";
}
else if (num_grade1 <= 94 && num_grade1
>= 90){
document.getElementById("letGrade1").value = "A";
}
else if (num_grade1 <= 89 && num_grade1
>= 85){
document.getElementById("letGrade1").value = "A-";
}
else if (num_grade1 <= 84 && num_grade1
>= 80){
document.getElementById("letGrade1").value = "B+";
}
else if (num_grade1 <= 79 && num_grade1
>= 75){
document.getElementById("letGrade1").value = "B";
}
else if (num_grade1 <= 74 && num_grade1
>= 70){
document.getElementById("letGrade1").value = "B-";
}
else if (num_grade1 <= 69 && num_grade1
>= 65){
document.getElementById("letGrade1").value = "C+";
}
else if (num_grade1 <= 64 && num_grade1
>= 60){
document.getElementById("letGrade1").value = "C";
}
else if (num_grade1 <= 59 && num_grade1
>= 50){
document.getElementById("letGrade1").value = "D";
}
else if (num_grade1 < 50){
document.getElementById("letGrade1").value = "F";
}
if (num_grade2 > 94){
document.getElementById("letGrade2").value = "A+";
}
else if (num_grade2 <= 94 && num_grade2
>= 90){
document.getElementById("letGrade2").value = "A";
}
else if (num_grade2 <= 89 && num_grade2
>= 85){
document.getElementById("letGrade2").value = "A-";
}
else if (num_grade2 <= 84 && num_grade2
>= 80){
document.getElementById("letGrade2").value = "B+";
}
else if (num_grade2 <= 79 && num_grade2
>= 75){
document.getElementById("letGrade2").value = "B";
}
else if (num_grade2 <= 74 && num_grade2
>= 70){
document.getElementById("letGrade2").value = "B-";
}
else if (num_grade2 <= 69 && num_grade2
>= 65){
document.getElementById("letGrade2").value = "C+";
}
else if (num_grade2 <= 64 && num_grade2
>= 60){
document.getElementById("letGrade2").value = "C";
}
else if (num_grade2 <= 59 && num_grade2
>= 50){
document.getElementById("letGrade2").value = "D";
}
else if (num_grade2 < 50){
document.getElementById("letGrade2").value = "F";
}
if (num_grade3 > 94){
document.getElementById("letGrade3").value = "A+";
}
else if (num_grade3 <= 94 && num_grade3
>= 90){
document.getElementById("letGrade3").value = "A";
}
else if (num_grade3 <= 89 && num_grade3
>= 85){
document.getElementById("letGrade3").value = "A-";
}
else if (num_grade3 <= 84 && num_grade3
>= 80){
document.getElementById("letGrade3").value = "B+";
}
else if (num_grade3 <= 79 && num_grade3
>= 75){
document.getElementById("letGrade3").value = "B";
}
else if (num_grade3 <= 74 && num_grade3
>= 70){
document.getElementById("letGrade3").value = "B-";
}
else if (num_grade3 <= 69 && num_grade3
>= 65){
document.getElementById("letGrade3").value = "C+";
}
else if (num_grade3 <= 64 && num_grade3
>= 60){
document.getElementById("letGrade3").value = "C";
}
else if (num_grade3 <= 59 && num_grade3
>= 50){
document.getElementById("letGrade3").value = "D";
}
else if (num_grade3 < 50){
document.getElementById("letGrade3").value = "F";
}
var avg_numerical_score =
parseInt(parseInt(num_grade1) + parseInt(num_grade2) +
parseInt(num_grade3)) / 3
alert("Numerical Average score: " +
avg_numerical_score.toFixed(2))
}
Images of the code for indentation reference:
Python code, partB_.py
Editable code:
person_name = str(input("Enter your name: "))
num_grade1 = int(input("Enter your Numerical Grade 1 (0 to 100):
"))
num_grade2 = int(input("Enter your Numerical Grade 2 (0 to 100):
"))
num_grade3 = int(input("Enter your Numerical Grade 3 (0 to 100):
"))
if num_grade1 == "":
num_grade1 = 0
if num_grade2 == "":
num_grade2 = 0
if num_grade2 == "":
num_grade2 = 0
if (num_grade1 > 94):
print ("%s ---> %s" %(num_grade1, "A+"))
elif (num_grade1 <= 94 and num_grade1 >= 90):
print ("%s ---> %s" %(num_grade1, "A"))
elif (num_grade1 <= 89 and num_grade1 >= 85):
print ("%s ---> %s" %(num_grade1, "A-"))
elif (num_grade1 <= 84 and num_grade1 >= 80):
print ("%s ---> %s" %(num_grade1, "B+"))
elif (num_grade1 <= 79 and num_grade1 >= 75):
print ("%s ---> %s" %(num_grade1, "B"))
elif (num_grade1 <= 74 and num_grade1 >= 70):
print ("%s ---> %s" %(num_grade1, "B-"))
elif (num_grade1 <= 69 and num_grade1 >= 65):
print ("%s ---> %s" %(num_grade1, "C+"))
elif (num_grade1 <= 64 and num_grade1 >= 60):
print ("%s ---> %s" %(num_grade1, "C"))
elif (num_grade1 <= 59 and num_grade1 >= 50):
print ("%s ---> %s" %(num_grade1, "D"))
elif (num_grade1 < 50):
print ("%s ---> %s" %(num_grade1, "F"))
if (num_grade2 > 94):
print ("%s ---> %s" %(num_grade2, "A+"))
elif (num_grade2 <= 94 and num_grade2 >= 90):
print ("%s ---> %s" %(num_grade1, "A"))
elif (num_grade2 <= 89 and num_grade2 >= 85):
print ("%s ---> %s" %(num_grade2, "A-"))
elif (num_grade2 <= 84 and num_grade2 >= 80):
print ("%s ---> %s" %(num_grade2, "B+"))
elif (num_grade2 <= 79 and num_grade2 >= 75):
print ("%s ---> %s" %(num_grade2, "B"))
elif (num_grade2 <= 74 and num_grade2 >= 70):
print ("%s ---> %s" %(num_grade1, "B-"))
elif (num_grade2 <= 69 and num_grade2 >= 65):
print ("%s ---> %s" %(num_grade2, "C+"))
elif (num_grade2 <= 64 and num_grade2 >= 60):
print ("%s ---> %s" %(num_grade2, "C"))
elif (num_grade2 <= 59 and num_grade2 >= 50):
print ("%s ---> %s" %(num_grade2, "D"))
elif (num_grade2 < 50):
print ("%s ---> %s" %(num_grade2, "F"))
if (num_grade3 > 94):
print ("%s ---> %s" %(num_grade3, "A+"))
elif (num_grade3 <= 94 and num_grade3 >= 90):
print ("%s ---> %s" %(num_grade3, "A"))
elif (num_grade3 <= 89 and num_grade3 >= 85):
print ("%s ---> %s" %(num_grade3, "A-"))
elif (num_grade3 <= 84 and num_grade3 >= 80):
print ("%s ---> %s" %(num_grade3, "B+"))
elif (num_grade3 <= 79 and num_grade3 >= 75):
print ("%s ---> %s" %(num_grade3, "B"))
elif (num_grade3 <= 74 and num_grade3 >= 70):
print ("%s ---> %s" %(num_grade3, "B-"))
elif (num_grade3 <= 69 and num_grade3 >= 65):
print ("%s ---> %s" %(num_grade3, "C+"))
elif (num_grade3 <= 64 and num_grade3 >= 60):
print ("%s ---> %s" %(num_grade3, "C"))
elif (num_grade3 <= 59 and num_grade3 >= 50):
print ("%s ---> %s" %(num_grade3, "D"))
elif (num_grade3 < 50):
print ("%s ---> %s" %(num_grade3, "F"))
numerical_avg = (num_grade1 + num_grade2 + num_grade3) / 3
print ("Average Numerical score: %.2f" %(numerical_avg))
if (numerical_avg > 94):
print ("%.2f ---> %s" %(numerical_avg, "A+"))
elif (numerical_avg <= 94 and numerical_avg >= 90):
print ("%.2f ---> %s" %(numerical_avg, "A"))
elif (numerical_avg <= 89 and numerical_avg >= 85):
print ("%.2f ---> %s" %(numerical_avg, "A-"))
elif (numerical_avg <= 84 and numerical_avg >= 80):
print ("%.2f ---> %s" %(numerical_avg, "B+"))
elif (numerical_avg <= 79 and numerical_avg >= 75):
print ("%.2f ---> %s" %(numerical_avg, "B"))
elif (numerical_avg <= 74 and numerical_avg >= 70):
print ("%.2f ---> %s" %(numerical_avg, "B-"))
elif (numerical_avg <= 69 and numerical_avg >= 65):
print ("%.2f ---> %s" %(numerical_avg, "C+"))
elif (numerical_avg <= 64 and numerical_avg >= 60):
print ("%.2f ---> %s" %(numerical_avg, "C"))
elif (numerical_avg <= 59 and numerical_avg >= 50):
print ("%.2f ---> %s" %(numerical_avg, "D"))
elif (numerical_avg < 50):
print ("Average Grade: %.2f ---> %s"
%(numerical_avg, "F"))
Images of the code for indentation reference:
All the images of the code and editable formats also submitted, No bugs are there.
Get Answers For Free
Most questions answered within 1 hours.