Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is for my beginners programming class, this section is Intro to Javascript.

ID: 3555298 • Letter: T

Question

This is for my beginners programming class, this section is Intro to Javascript. So in order to get the points, it has to be as simple as possible, but also has to work ofcourse.

Thank you

1. Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording the number of miles driven and the number of gallons used for each tankful. Develop a script that will take as input the miles driven and gallons used (both as integers) for each tankful. The script should calculate and output HTML5 text that displays the number of miles per gallon obtained for each tankful and prints the combined number of miles per gallons obtained for all tankfuls up to this point. Use prompt dialogs to obtain the data from the user.

2. Develop a script that will determine whether a department-store customer has exceeded the credit limit on a charge account. For each customer, the following facts are available:
a) Account number
b) Balance at the beginning of the month
c) Total of all items charged by this customer this month
d) Total of all credits applied to this customer's account this month
e) Allowed credit limit
The script should input each of these facts from a prompt dialog as an integer, calculate the new balance (= beginning balance + charges - credits), display the new balance and determine whether the new balance exceeds the customer's credit limit. For customers whose credit limit is exceeded, the script should output HTML5 text that displays the message "Credit limit exceeded."

Explanation / Answer

1) Code for the first part:

2) Code for the second Part:

  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  
  <!DOCTYPE html>  <html>          <meta charset="utf-8">          <head>                  <title>Eyal's Mileage Calculator</title>                  <script type="text/javascript">                          var n1;                           var n2;                           var n3;                           var gallon;                           var miles;                           var tankCount;                           var totalMiles;                           var totalGallons;                           var totalMileage;                           var i;                           //Initialisations start here                          total = 0;                           tankCount = 0;                           totalMiles = 0;                          totalGallons = 0;                          i = 0;                                    n1 = window.prompt( "How many tanks of gas used?" );                          tankCount = parseInt(n1);                          while( tankCount != 0 )                            {                                  i++;                                    n2 = window.prompt( "How many miles driven?" );                                  n3 = window.prompt( "How many gallons of gas used?" );                                  miles = parseInt( n2 );                                  gallon = parseInt( n3 );                                  total = miles / gallon;                                  document.writeln("For tank " + i + " the miles per gallon was " + total );                                  document.writeln("<br />");                                  totalMiles = totalMiles + miles;                                  totalGallons = totalGallons + gallon;                                  totalMileage = totalMiles / totalGallons;                                  document.writeln( "The total miles per gallon was " + totalMileage );                                  document.writeln("<br />");                                  document.writeln("<br />");                                  tankCount--;                              }                  </script>          </head>          <body></body>  </html>  
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote