Exercises

Goat

Many of these were exams (exam 1) in the past.

Exercise

Your simple program

Write a program like the tip calculator, length converter, and Aussie Rules scorer. When a button is pressed, it should take some input from the worksheet, do some calculation(s), and output to the worksheet, using the IPO pattern. Input and output can be numeric and/or string.

Add a comment for each part of your IPO code, like "Arr! Here be input, maties!" You don't have to do Pirate, though.

Use good variable names, Option Explicit, and other things you need.

Upload your worksheet.

Exercise

Questions

Write a program that asks the user about their name, their dog's name, and shows a message. All input and output is with dialogs. First, the program asks for the user's first name:

First name

Then the last name:

Last name

Then the dog's name:

Dog's name

That's all the input. After that, your program shows a message, that puts together the data:

Output

Format the message exactly, with the right spacing, and the line breaks.

Notice something else you need to do. The user might type extra spaces around their input, like they did with the dog name.

Dog's name

Make sure the extra spaces do not affect the output.

Another run sequence:

First name

Last name

Dog name

Output

Upload your worksheet. The usual coding standards apply. Good variable names, like that.

Exercise

Cylinder covering

Write a program to help users work out how much fabric they need to make a covering for their fave cylinder. The input should be from the worksheet, like this:

Input

I asked Google how to work out the surface area of a cylinder. It said:

Surface area formula

Here's the output for that data:

Output

Problem, though. The input is in centimeters. The output should be in square meters. I asked Google about that, too.

Square cm to square meters

Another example. The input:

Input

Output:

Output

Upload your workbook. The usual standards apply.

Exercise

XP

Write a program that computes how many experience points (XP) a player earns in a game. They earn XP from killing things like rats, and zombies. You can download this starting workbook.

Here's the start screen:

Start

The user enters numbers in the cells, and clicks the button. Here's some sample output:

Output

Here's what each critter is worth:

Critter XP each
Bat 5
Rat 7
Wolf 20
Zombie 25
Goblin 30
Hobgoblin 50

Upload your solution. The usual coding standards apply.

Exercise

Food order

Write a program to compute the price of a goaty food order. You can download a starting workbook. Here's what it looks like to start:

Start

Users type in the number of each item they want to order. Your program works out the total food cost, total drink cost, total service charge, and the overall total. Here some output:

Output

Write a program to do this.

Important! Your code should get all the prices from the worksheet. Your code should not have 14.95 anywhere in it. Nor 2.95. Nor 0.75. Etc.

You don't need to round the prices to the nearest cent. If you want to, this page explains how.

Include comments identifying each of the three parts of the program.

Upload your solution. The usual standards (variable name standards, indenting, maybe other stuff you've learned) apply.

Exercise

Goatercise

Write a program to work out how many calories a goaty workout will burn. You can download a start worksheet. It looks like this:

Start

Users fill in the green cells, and click the button. They see the calories their workout would burn. Here's how much toning exercises burn per rep:

Exercise Calories for one rep
Butt heads 20
Foreleg curl 14
Angst 27

Calories for a toning exercise are the number of sets, times the reps per set, times the value above, like 20.

Here's the burn for cardio:

Exercise Calories per minute
Treadmill 180
Unicycle 320
Worried pacing 90

Here's some output:

Output

Some more:

Output

Upload your solution to this site, not to Moodle. The usual coding standards apply.

Exercise

The Bonnie Burns Effect

Nobody Listens to Paula Poundstone is your comedy field guide to life. The podcast features Paula, her cohost Adam (who is on every show), Toni, and the redoubtable Bonnie Burns.

Paula's assistant Wendell noticed the more Bonnie is on the show, the more merch they sell, but the lower their sponsorship revenue is. Sponsors are nervous about Bonnie, who might, for example, use "alternative facts" about her age to get a better deal, or lure Toni into a life of breakfast crime.

Bonnie also drives some people to despair. The show has had to pay for psychiatric care for Adam and Vic, the show's sound editor.

Some of Bonnie's antics pose legal risks, such as a threatened lawsuit by the estate of Zero Mostel. The show seeks legal advice before releasing a Bonnie-ridden episode.

Write a VBA program to estimate the revenue effect of each minute Bonnie is talking on the show. You can download a start worksheet. It looks like this:

Start

The user fills in values in the input part, above the Run button. They click the button, and get the output.

  • Add in the effect of merch and sponsor changes.
  • Adam needs two hours of psychiatric care for each minute Bonnie talks.
  • Vic needs three hours per minute, since he has to listen to Bonnie speak more than once while he's editing the show.
  • The show needs one hour of legal advice for each minute Bonnie talks.

Here's some sample output:

Output

Use the IPO pattern. Add a comment identifying each of the three parts of the program.

Upload your workbook with the VBA code here. The usual standards (variable naming, indentation, secluded cells, explicit variables) apply.

Exercise

Mars shot

Cthulhu is planning a trip to Mars. A few goats will live in Earth's first base on another planet. Help him work out consumables needed for the trip. You can download a start worksheet.

The worksheet starts like this:

Start

Small goats need 60 kilos of feed per month, medium goats need 130, and large goats need 200. (Assume goats don't grow during the voyage.) Space-grade goat food costs $32.50 per kilo.

Water is recycled, but there's some loss every month. To top them up, small goats need 2.2 liters per month, medium goats need 5.1, and large goats need 9.4. Space-grade goat water costs $17.23 per liter.

Oxygen is recycled, too, but there's also some loss every month. To top them up, small goats need 2.8 liters per month, medium goats need 6.9, and large goats need 12.3. Space-grade goat oxy costs $31.84 per liter.

Users fill in the number of goats and the voyage length, then hit the button. Here's some output:

Output

Submit your solution to this site as usual, not to Moodle. The usual coding standards apply, including secluded cells.