Question

PART B- Javascript Using a text editor (VS Code or Notepad) and a web browser, you...

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)

  1. Output the name and number grades to the HTML DOM using the IDs provided on below table
  2. When the button is pushed
    1. Have the letter grades (@Assignment Data)calculated and the HTML DOM updated for each grade.
    2. Have the numerical average alerted to the user.

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.

  • Create a blank Python file. The file name should be partB_.py or partB.ipynb.  
  • Ask the user for input for a Student name and ask for 3 numeric grades (0 to 100)
    1. Have the letter grades calculated and output for each grade.
    2. Have the numerical average calculated and output to the user.
    3. Calculate the letter grade of the numerical average and output to the user.

Homework Answers

Answer #1

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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Part 1: Create the grid tic-tac-toe gameboard using buttons and iteration. Part 2: Human user gets...
Part 1: Create the grid tic-tac-toe gameboard using buttons and iteration. Part 2: Human user gets to select an open cell on the grid - place an X on that button selected Part 3: Check for a win using DOM iteration - new game option if row or column matching X pattern Part 4: Computer gets to select an open cell on the grid - place an O on that button selected Part 5: Check for a win using DOM...
Please linked both files. For this assignment you need to create a ToDo list using Javascript,...
Please linked both files. For this assignment you need to create a ToDo list using Javascript, along with HTML and CSS. Begin by creating a HTML page called todo.html. Then create a Javascript file called todo.js and link it in to the HTML page using a script tag. All Javascript for the assignment must be in the separate file. (For CSS, feel free to include styles in a style block at the top of the HTML page, or to link...
I am trying to make a contact form to give input on another browser window. I...
I am trying to make a contact form to give input on another browser window. I am only getting the php code. I am trying to figure out why it won't post. Her is my html and php files: <!DOCTYPE html> <html> <head> <title>Contact</title> <link rel="stylesheet" href="main.css"> </head> <body>    <h1>Contact Form</h1> <nav> <ul> <li><a href="index.html">Home</a></li> <li><a href="page2.html">My PodCast</a></li> <li><a href="page3.html">Contact Me</a></li> <li><a href="page4.html">Resources</a></li> <li><a href="addressbook.html">Address Book</a></li> <li>Contact Form</li> </ul> </nav> <center><h2>Please fill out form</h2> <div id='container'> <div id='header'></div> <center><h3>Contact</h3>...
Hi, there. A question about web development. I'm using the jquery to try the reset method...
Hi, there. A question about web development. I'm using the jquery to try the reset method in an input form in the PHP file but it didn't work. Here is a part of my code. <div id='signbox' class='modal-window'> <form id= 'signF' method='post' action='centerControl.php'> ... <input id='resetSign' type='button' value ='Reset'>; ... </form> </div> <script> $(document).ready(function(){ $("#resetSign").click(function(){ $("#signF")[0].reset() }); }); </script> And one more question that I'm a new player so what kind of tool I can check all my jquery PHP...
This will be my third time submitting this question. THERE SHOULD BE NO USE OF CSS...
This will be my third time submitting this question. THERE SHOULD BE NO USE OF CSS OR SWITCH STATEMENTS IN THE JAVASCRIPT. Even though there is stylesheet in the HTML file do no create a new one. Project Standards: Students will use click events to capture user input. Students will use variables to store information needed by their application and keep track of their program’s state. Students will use conditionals to control project flow. Project Task You will be building...
For this assignment you'll be creating an application that has the user input a subtotal, tax...
For this assignment you'll be creating an application that has the user input a subtotal, tax rate and tip percentage and then displays the sales tax, tip amount and the total. You'll use JQuery instead of the getElementByX functions AND you will display all messages on the page (no alert or prompt boxes) The starter file is based off of the Lab 2 sales_tax application. Feel free to borrow code from your lab solution but realize you will need to...
Using python, write the program below. Program Specifications: You are to write the source code and...
Using python, write the program below. Program Specifications: You are to write the source code and design tool for the following specification: A student enters an assignment score (as a floating-point value). The assignment score must be between 0 and 100. The program will enforce the domain of an assignment score. Once the score has been validated, the program will display the score followed by the appropriate letter grade (assume a 10-point grading scale). The score will be displayed as...
In HTML and Javacript: Create three columns. Column #1: Include input fields for the following... Text...
In HTML and Javacript: Create three columns. Column #1: Include input fields for the following... Text field (with labelling) to retrieve a student's FIRST name Text field (with labelling) to retrieve a student's last name Text field (with labelling) to retrieve a student's id (number) A checkbox for country designation with no check designating a "Domestic" student and checked designating an "International" student. A text field should be placed beside or under the check box with the text field containing...
Java Script I need the code to produce these 3 output. I can only get it...
Java Script I need the code to produce these 3 output. I can only get it to produce input #3 I need it to produce the following: // Input #1: // http://www.example.com // Output // http://www.example.com // Input #2: // http://www.example.com?name=r2d2 // Output // http://www.example.com // name: r2d2 // Input #3: // http://www.example.com?name=r2d2&email=r2d2%40me.com&human=no // Output // http://www.example.com // name: r2d2 // email: [email protected] // human: no THIS IS WHAT I HAVE SO FAR: HTML <!DOCTYPE html> <html lang="en"> <head> <meta...
I need python code for this. Write a program that inputs a text file. The program...
I need python code for this. Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. Uppercase words should take precedence over lowercase words. For example, 'Z' comes before 'a'. The input file can contain one or more sentences, or be a multiline list of words. An example input file is shown below: example.txt the quick brown fox jumps over the lazy dog An example of the program's output...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT