Objective

To practice variable declaration, conditional, and iteration statements.

Overview

For this project you will write a JavaScript program for each of the following problems. Each program will appear in a separate html file. You do not need to provide pseudocode unless otherwise specified.

  1. Write a program that reads the following information about a person's car.
    1. The miles per gallon for the car.
    2. How many miles the person is planning to travel.
    3. What is the cost of gas per gallon.
    Using the above information compute how much money in gas the person will have to pay in order to complete a trip. Name the file trip.html.
  2. Write a program that computes a student's ranking based on number of credits. The program will read the number of credits, and compute the ranking based on the following criteria:
    1. Graduating - if the number of credits is 120 or above
    2. Pre-Graduation - if the number of credits is greater than or equal to 90 and less than 120
    3. In-Progress - if the number of credits is greater than or equal to 50 and less than 90
    4. Just-Starting - if the number of credits is less than 50

    The program will display the message "Graduating", "Pre-Graduation", "In-Progress", or "Just-Starting".
    Name the file ranking.html
  3. Write a program that calculates simple interest and compound interest for a particular amount (principal), at particular rate for a period of years. The program will display a table with the total amount (including principal) per year. The formula to compute simple interest is "interest = principal * (rate/100) * years". Just add the principal to the interest to generate the amount to display. The formula to compute compound interest is "FinalAmount = principal * (1 + rate/100)Years". Notice that you do not need to add the principal in this case.

    Your program must read the principal amount, rate (%), and the maximum number of years. The following is an example of running the program using the $1000, 5% and 15 as the maximum number of years (Example). Keep in mind this is just an example. Your program must work with different values (e.g., different number of years, different rates, etc.).

    Use the following messages to read the appropriate values:
    1. "Enter principal"
    2. "Enter rate (percentage value)"
    3. "Enter number of years"

    Notice that at the top of the table you will see the message "Table for " followed by the principal amount and the rate. Name the file interest.html

Requirements