

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


HW#1, 40 points total Due: Midnight, Wednesday, 9/ Submit your programs/code via Blackboard
Algorithm Design
To test your algorithm, an input of 26.2 miles, 3 hours, 16 minutes, and 30 seconds should result in a pace of 7:30 per mile.
For this part, give an algorithm only, do not write code.
Short Answer
2. (4 points) Given the algebraic equation
y = ax^3 + 2x + 7
Which of the following, if any, are correct Java statements for this equation? a. y=axxx+2x+7; b. y=axxx+2(x+7); c. y=a(xxx+(2x)+7); d. y=(ax)xx+7+x2; e. y=a(xxx)+(2x)+7;
3. (4 points) State the order of evaluation of the operators in each of the following Java statements, and show the value of x after each statement is performed. a. x=7+36/2-1; b. x=2 % 2+22-2/2; c. x=(39(3+(9*3/(3))));
Programming Exercises
For programming exercises, turn in a copy of your code. For all exercises use the Unix environment, not TextPad or 5etBeans. We will mostly use TextPad or NetBeans for the rest of the class, but you’ll have your choice of which environment to use. Turn in your Java files along with any other answers. Your answers can be placed in a word document or textfile.
Fill in the following comment header for all your programs. Add additional comments in your program as you deem necessary.
////////////////////////////////////////////////////// // CS //
4. (6 points) One way to measure the amount of energy that is expended during exercise is to use metabolic equivalents (MET). Here are some METS for various activities:
Running 6 MPH: 10 METS Basketball: 8 METS Sleeping: 1 MET
The number of calories burned per minute may be estimated using the formula:
Calories/Minute = 0.0175 × MET × Weight(Kg)
Write a program that inputs a person’s:
Implement the running pace calculator described in problem 1. Here is a sample of the desired behavior:
Example (user input in bold): Input distance in miles: 26. Input hours run: 3 Input minutes run: 16 Input seconds run: 30 Your race pace is 7:30 per mile