MP2: MovieSurvey

Learning Objectivies

Introduction

This program asks the users how they watch movies (cinema, DVD player, computer) and summarizes the results. The program you write should work as follows:

Clarification

You must match our formatting exactly for anything that is printed to the screen by your program!! Please make sure you capitalize correctly, put the spaces where they are supposed to go, use the right words, and so on. There is no "partial credit" for getting things "sort of" right; even forgetting a period or a capital letter means your output is wrong. This is why you need to use the automated testing to check your output is exactly correct—if you only check your results by eye, you are likely to miss something.

Formatting 2 Decimal Places

To get the two decimal precision we expect for the output, you might want to try something like this:

double percentage;
percentage = 50;
TextIO.putf("%.2f", percentage);

The "%.2f" tells TextIO how to format the output of percentage. That is, "%.2f" tells TextIO that you need 2 precision of two decimal places. In your MP, percentage won't equal 50; it will be computed based on the input provided by the user.

Example Output

Example #1 - The user input is 3\n5\n11\n .... \n means newline i.e. the enter key is pressed

Welcome. We're interested in how people are watching movies this year.
Thanks for your time. - The WRITERS GUILD OF AMERICA.
Please tell us about how you've watched movies in the last month.
How many movies have you seen at the cinema?
How many movies have you seen using a DVD or VHS player?
How many movies have you seen using a Computer?
Summary: 3 Cinema movies, 5 DVD/VHS movies, 11 Computer movies
Total: 19 movies
Fraction of movies seen at a cinema: 15.79%
Fraction of movies seen outside of a cinema: 84.21%

Example #2 User input is 1\n101\n98\n

Welcome. We're interested in how people are watching movies this year.
Thanks for your time. - The WRITERS GUILD OF AMERICA.
Please tell us about how you've watched movies in the last month.
How many movies have you seen at the cinema?
How many movies have you seen using a DVD or VHS player?
How many movies have you seen using a Computer?
Summary: 1 Cinema movies, 101 DVD/VHS movies, 98 Computer movies
Total: 200 movies
Fraction of movies seen at a cinema: 0.50%
Fraction of movies seen outside of a cinema: 99.50%