Write "Node.js" Code

ghtyui52000
Node.jscodeAssignment.docx

Write a the Node.js Code for these

1. Total Purchase

A customer in a store is purchasing five items. Write a program that asks

// for the price of each item, then displays the subtotal of the sale, the

// amount of sales tax, and the total. Assume the sales tax is 7 percent.

2. Total Distance

Assuming there are no accidents or delays, the distance that a car travels

// down the interstate can be calculated with the following formula:

//

//  Distance=Speed * Time

//

// Write a program that prompts for both Speed and Time and calculates and

// displays the distance traveled.

3. Sales tax

// Write a program that will ask the user to enter the amount of a purchase.

// The program should then calculate the state and county sales tax

// Assume the state sales tax is 5 percent and the county sales tax is 2.5

// percent. The function should display the total for the purchase including the

// original purchase price plus state sales tax and county sales tax.

//

// Hint: Use the value 0.025 to represent 2.5 percent, and 0.05 to represent 5 percent.

4.

Write a program that asks the user to enter a person's age. The program should

// display a indicating whether the person is an infant, a child, a teenager, or

// an adult. Following are the guidelines:

//

// If the person is 1 year old or less, he or she is an infant.

// If the person is older than 1 year, but younger than 13 years, he or she is a child.

// If the person is at least 13 years old, but less than 20 years old, he or she is a teenager.

// If the person is at least 20 years old, he or she is an adult.

5.

// Write a program that prompts the user to enter a number within the range of 1

// through 10 and displays the roman numeral version of that number. If the number

// is outside the range of 1 through 10, the program should display an error message.

//

// The following table shows the Roman numerals for the numbers 1 through 10:

//      1 = I       4 = IV      7 = VII     10 = X

//      2 = II      5 = V       8 = VIII

//      3 = III     6 = VI      9 = IX

6. Scientists measure an object’s mass in kilograms and its weight in newtons.

// If you know the amount of mass of an object in kilograms, you can calculate

// its weight in newtons with the following formula:

//

//      weight=mass×9.8

//

// Write a program that asks the user to enter an object’s mass, then calculates

// and displays the object's weigh in newtown. If the object weighs

// more than 500 newtons, display a message indicating that it is too heavy.

// If the object weighs less than 100 newtons, display a message indicating

// that it is too light.