Part A: (ungraded) Read Chapters 4 & 15. Look at the review questions for each chapter. Recommended exercises to do on your own as practice for the midterm: 4.2, 4.3, 4.5, 4.6. Write and run a JAVA program to check your answers. You are permitted to work together on any ungraded work for the course. Your midterm is Monday 3/4, Chapters 1-4, 11. There are practice tests on the main course webpage.
Part B: [10 points] Create a long sample run for program 3B below that can be used to thoroughly test its operation. You should choose each menu operation multiple times, and in varying orders. It's up to you to specify what the user types to make each menu choice, but we recommend a single letter or number. Be sure to consider all cases your program needs to handle and how the output will look. Type your sample run in plain text file w3.txt and submit on Blackboard as usual.
Part A: Binary to Decimal Conversion [15 pts]
For this first exercise in working with loops, you must implement the binary to decimal conversion problem for which you wrote pseudocode in assignment 2 warm-up part C. (We strongly recommend reviewing the posted solution to make sure your implementation will be correct.) The overall operation of your program must be to read binary numbers from the user until s/he indicates the end of input. After each binary number is input, convert it to a decimal (base ten) and display the result. When you run a program like this, you must type either control-Z (Windows) or control-D (Mac) to indicate the end of input. You might need to hit the enter key afterwards as well.
Implementation Suggestion: first write a program that takes one binary number, converts it to base ten, and displays the result. Then add to the program so that it does this repeatedly until the end of input is indicated.
Part B: Exercise Tracker [35 pts]
This program will continue the theme of the exercise planner from assignment 1b. Now we want a menu-driven program to keep track of how much actual time we have spent exercising and the resulting calories burned over some period of time. We will use the same 4 exercise types and calories/hour that were in the first assignment, repeated here for convenience:
| Exercise | Calories/Hour |
|---|---|
| Running | 700 |
| Biking | 650 |
| Weight Lifting | 300 |
| Dancing | 400 |
[10 pts] For this assignment, you must gather data from the user for each time s/he exercises, prompting with a menu of exercise types. The user will choose the exercise type, and then input the duration of exercising in (whole) minutes. There should be a menu option to quit entering data as well. (Later we will enhance this to keep track of dates and get start and end times as input.)
[10 pts] Once the user has finished entering all the data, your program must display a nicely formatted table that has a row for each exercise type showing its total minutes and total calories burned. In the last row of the table, give a grand total of minutes spent and calories burned. Your table does not have to have borders, but the data should be lined up nicely in columns.
[10 pts] The final component of your program is to display a bar chart that visually represents how much time was spent in and how many calories were burned for each different activity. For the time display, output one '^' for every half hour, rounding the results. For the calorie display, output one '*' for every 500 calories, also rounding the results. Label each bar with the activity name. This component will be easiest to program as a horizontal bar chart. If you're looking for an extra challenge make it a vertical bar chart with the axis at the bottom as is commonly done.
[5 pts] As in the last assignment, use final to create constants for any numbers that are part of the problem definition, including the calories burned per hour for each exercise. Use good styling in general, including consistent indentation! Submit as usual.
General assignment requirements, style and submission details: