Physics and Astronomy |

Back to top
## Assessment 1This assessment forms 13% of your module mark. The objective is to test your ability to do simple arithmetic and do simple sanity-checking of users' input. Remember: you will make the best progress by doing the tasks in stages, making sure each stage works correctly before starting the next one. Be sure to ask me for help if you get stuck. Be sure to read the expectations document. ## 1. A grand day out35% of the assessment mark. Write a program to solve the following problems connected to the cost of a coach trip. As always, remember not to have numbers such as "159" scattered through the code but to use variables with sensible names. NB: the numbers below are indicative; you must write a program that gives the correct results whatever the number of students and instructors.
printf("%(Note: there is a decimal point after the percent sign, ie it is "percent point two f") A computing class has 159 students and eight instructors. They wish to take a trip to the National Museum of Computing at Bletchley Park. They can hire 16-seater minbuses for £81 each plus VAT at 20% (i.e. you must add 20% to £81 to get the total cost). - Calculate how many minbuses you will need and much will it cost to hire them.
- You estimate each van will do 31 miles per gallon and diesel costs £1.17 per litre. Use the internet or similar to find the distance from Exeter to Bletchley Park and the number of litres in a gallon and have your program use these numbers to calculate the estimated fuel cost.
- Calculate the total cost of the trip and the cost per person.
- Calculate the total amount of travelling expenses to be claimed by the instructors. (That is, the total for all the instructors, not the amount per instructor.)
## Output requiredJust the output from the program, for example: We require 6 vans which will cost 13212.87 The diesel will cost 123.56 The total cost is 13336.43 etc ## 2. The sine rule65% of the assessment mark. This assessment requires some basic checking of user
input. To do this you may either edit the program to manually
change the values of the variables or use
Revise the sine rule. - Write a program to read in two angles, in radians, (or manually set the values of the variables and change them for each case) and the length of the side between them. As always, use sensible variable names.
- Check these values for invalid values (ie those for which
could not be part of a triangle) and print a helpful message
for each class of error. (If you have chosen to use
`scanf()`you do not need to worry about the case where the user entered something that was not a number.) NB: the compiler defines the constantto be the value of π.**M_PI** - Calculate the other angle and the other two sides.
- Print out the sum of the three angles. (Why do you think we ask you to do this?)
- The area of the triangle can calculated from one angle and the length of the two sides that form it. Print out the area of the triangle calculated three times, once for each angle. (Why do you think we ask you to do this?)
## Output requiredThe output from your program runs should show some warnings from each class of non-valid input and one working case. ## To hand in
#include<stdio.h> int main() { The output should be fairly brief but enough to show that your code works. Basically we are looking for the minimum amount necessary to show your program worked for each separate class of the problem, including error checking where appropriate, rather than several similar runs. ## To copy and paste from the output terminalThe Windows output console has an "unusual" copy and paste mechanism: - Right-click in the console window and select "Select All".
- Press
**<Return>**.
You can now paste into Code::Blocks using Control-V |