0% found this document useful (0 votes)
36 views1 page

Machine Problem

The document describes two machine problems to solve using C# programs: 1. A program that calculates pet insurance fees based on type of pet and neutering status, asking the user to input animal details and offering to calculate additional fees. 2. A program that helps a health visitor create statistics on pupil heights by reading in a class's height data in cm, then outputting a table with height values, number of pupils of each height, and the average height.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

Machine Problem

The document describes two machine problems to solve using C# programs: 1. A program that calculates pet insurance fees based on type of pet and neutering status, asking the user to input animal details and offering to calculate additional fees. 2. A program that helps a health visitor create statistics on pupil heights by reading in a class's height data in cm, then outputting a table with height values, number of pupils of each height, and the average height.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Machine Problem: 1.

Animal insurance Write a C# program that prints the insurance fee to pay for a pet according to the following rules:

A dog that has been neutered costs $50. A dog that has not been neutered costs $80. A cat that has been neutered costs $40. A cat that has not been neutered costs $60. A bird or reptile costs nothing. Any other animal generates an error message.

The program should prompt the user for the appropriate information, using a code to determine the kind of animal (i.e. D or d represents a dog, C or c represents a cat, B or b represents a bird, R or r represents a reptile, and anything else represents some other kind of animal). After printing the insurance fee, the program should ask the user if (s)he wants to insure another animal. Remember to write the program in a clear style with indentation. 2. Pupils' heights The health visitor at a school is going to measure the heights of all pupils. For each class she makes a statistics giving the number of pupils of each height and the average height. Make a C# program that helps the health visitor making the statistics. Example: In a class with 20 pupils the heights of the individual pupils, in centimeters, are: 175, 167, 160, 164, 183, 187, 188, 179, 176, 175, 169, 175, 176, 178, 165, 160, 173, 165, 187, 178 The program should read in all the numbers and make a table like this: height 160 164 165 167 ... ... 188 average height 174.0 number of pupils 2 1 2 1 ... ... 1

You might also like