Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Worksheet 1 Input, Calculation and Variables Short Assessed Programming Exercise 1, Input, Calculation and Variables To pass this exercise you must demonstrate that you are

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Worksheet 1 Input, Calculation and Variables Short Assessed Programming Exercise 1, Input, Calculation and Variables To pass this exercise you must demonstrate that you are able to do the following in solving the problem EXPLAIN HOW YOUR PROGRAM WORKS a Write a program that uses input instructions Write a program that uses variables Write a program that uses arithmetic expressions Write a program that makes simple use of comments - at least the author's name and date and explanation of what the program does overall When your program works, explain it to a student, test it and check if it ticks all the boxes. If you are having problems or don't understand the requirements, ask for help. Student Loan Calculation A Student Loan company is providing an online calculator for students to work out how much they owe. They first input how much they owed at the start of the year, then how much they paid off that year. You may assume these are in whole numbers of pounds. It then adds 6.3% interest to the total at the end of the year and prints out the new total. The final answer should be given to two decimal places (rounded). HINT: You can do this by using the built-in round() function I An example run of the program is as follows (numbers in bold are typed in by the user): Amount of loan at start of year? 1000 Amount paid off this year? 5 The new amount owed is (in pounds): 1057.69 Another example run: Amount of loan at start of year? 1000 Amount paid off this year? 6 The new amount owed is (in pounds): 1056.62 GRADING: Your program will be marked taking into account the next boxes The program runs correctly for all input (not just the examples above) including extreme values. [15 marks] The program should clearly indicate what should be typed when the user is needed to enter values (including indicating values not acceptable). [15 marks] This program is now more complicated. You cannot just run it once and see if it works as what it does depends on the values input. You will need to run it lots of times -enough to convince yourself it always works. What about extreme values -- very big or very small? Zero is always a good value to test for. For this exercise, if the program crashes when bad values are entered that is ok as long as the user was wamed in some way not to type those values beforehand. Check if the correct answer is given. Check carefully there are no missing spaces or punctuation in the output. Inspecting your code by eye, including checking if all variables are given a value before the value is used, is always a good idea. Check the comments to make sense. Making Decisions Short Assessed Programming Exercise 2: Making Decisions To pass this exercise you must demonstrate that you are able to do the following in solving the problem O EXPLAIN HOW YOUR PROGRAM WORKS Write a program that uses if-then-else constructs. Write a program that includes useful comments, at least one per method saying what it does. Write a program that uses indentation in a way that makes its structure clear. When your program works, explain it to a student, test it and check it ticks all the boxes, If you are having problems or don't understand the requirements, ask for help. Body Age Write a program that estimates a person's body age - whether they are ageing faster or slower than their actual years - as a measure of how fit and healthy they are. This simplified test is based on the person inputting their actual age in years, their heart rate (beats in a minute) and how far they can stretch forward when sitting on the floor to the nearest cm). This is the distance between where their fingers fall when back straight and where they fall when stretching forward without bending knees. The calculation is done as follows. Take their actual age and add or subtract years to it as follows: Heart rate of less than 60, subtract 4 Heart rate of 60-64, subtract 2. Heart rate of 65-72, add 1. Heart rate of 73 or more, add 2 Next modify the resulting age based on the distance they can stretch: Stretch less than 25cm add 3 Stretch 25-36cm: add 2. Stretch 37cm, add 0. Stretch 38-40cm, subtract 2. Stretch more than 40cm, subtract 3 An example run of the program (words in bold are typed in by the user): What is your age? 55 What is your resting heart rate? 66 How far can you stretch? 37 Your body's age is 56 Another example run: What is your age? 21 I What is your resting heart rate? 61 How far can you stretch? 42 Your body's age is 16 GRADING Your program will be marked taking into account the next boxes The program runs correctly for all input. [10 marks] All branches of the IF-THEN-ELSE constructs work (20 marks) The program deals with input it doesn't know about [10 marks) Decision statements add a new level of difficulty for testing. You need to make sure every line works, but when you run the code some of the lines are not executed - as in any If statement either the then case or the else case is executed not both. You must test the program by running it lots of times with different values, choosing values that will definitely test all the lines of code (so test all branches) between them. Also remember to check carefully the output is right (spaces, punctuation, etc). Worksheet 1 Input, Calculation and Variables Short Assessed Programming Exercise 1, Input, Calculation and Variables To pass this exercise you must demonstrate that you are able to do the following in solving the problem EXPLAIN HOW YOUR PROGRAM WORKS a Write a program that uses input instructions Write a program that uses variables Write a program that uses arithmetic expressions Write a program that makes simple use of comments - at least the author's name and date and explanation of what the program does overall When your program works, explain it to a student, test it and check if it ticks all the boxes. If you are having problems or don't understand the requirements, ask for help. Student Loan Calculation A Student Loan company is providing an online calculator for students to work out how much they owe. They first input how much they owed at the start of the year, then how much they paid off that year. You may assume these are in whole numbers of pounds. It then adds 6.3% interest to the total at the end of the year and prints out the new total. The final answer should be given to two decimal places (rounded). HINT: You can do this by using the built-in round() function I An example run of the program is as follows (numbers in bold are typed in by the user): Amount of loan at start of year? 1000 Amount paid off this year? 5 The new amount owed is (in pounds): 1057.69 Another example run: Amount of loan at start of year? 1000 Amount paid off this year? 6 The new amount owed is (in pounds): 1056.62 GRADING: Your program will be marked taking into account the next boxes The program runs correctly for all input (not just the examples above) including extreme values. [15 marks] The program should clearly indicate what should be typed when the user is needed to enter values (including indicating values not acceptable). [15 marks] This program is now more complicated. You cannot just run it once and see if it works as what it does depends on the values input. You will need to run it lots of times -enough to convince yourself it always works. What about extreme values -- very big or very small? Zero is always a good value to test for. For this exercise, if the program crashes when bad values are entered that is ok as long as the user was wamed in some way not to type those values beforehand. Check if the correct answer is given. Check carefully there are no missing spaces or punctuation in the output. Inspecting your code by eye, including checking if all variables are given a value before the value is used, is always a good idea. Check the comments to make sense. Making Decisions Short Assessed Programming Exercise 2: Making Decisions To pass this exercise you must demonstrate that you are able to do the following in solving the problem O EXPLAIN HOW YOUR PROGRAM WORKS Write a program that uses if-then-else constructs. Write a program that includes useful comments, at least one per method saying what it does. Write a program that uses indentation in a way that makes its structure clear. When your program works, explain it to a student, test it and check it ticks all the boxes, If you are having problems or don't understand the requirements, ask for help. Body Age Write a program that estimates a person's body age - whether they are ageing faster or slower than their actual years - as a measure of how fit and healthy they are. This simplified test is based on the person inputting their actual age in years, their heart rate (beats in a minute) and how far they can stretch forward when sitting on the floor to the nearest cm). This is the distance between where their fingers fall when back straight and where they fall when stretching forward without bending knees. The calculation is done as follows. Take their actual age and add or subtract years to it as follows: Heart rate of less than 60, subtract 4 Heart rate of 60-64, subtract 2. Heart rate of 65-72, add 1. Heart rate of 73 or more, add 2 Next modify the resulting age based on the distance they can stretch: Stretch less than 25cm add 3 Stretch 25-36cm: add 2. Stretch 37cm, add 0. Stretch 38-40cm, subtract 2. Stretch more than 40cm, subtract 3 An example run of the program (words in bold are typed in by the user): What is your age? 55 What is your resting heart rate? 66 How far can you stretch? 37 Your body's age is 56 Another example run: What is your age? 21 I What is your resting heart rate? 61 How far can you stretch? 42 Your body's age is 16 GRADING Your program will be marked taking into account the next boxes The program runs correctly for all input. [10 marks] All branches of the IF-THEN-ELSE constructs work (20 marks) The program deals with input it doesn't know about [10 marks) Decision statements add a new level of difficulty for testing. You need to make sure every line works, but when you run the code some of the lines are not executed - as in any If statement either the then case or the else case is executed not both. You must test the program by running it lots of times with different values, choosing values that will definitely test all the lines of code (so test all branches) between them. Also remember to check carefully the output is right (spaces, punctuation, etc)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

50 Tips And Tricks For MongoDB Developers Get The Most Out Of Your Database

Authors: Kristina Chodorow

1st Edition

1449304613, 978-1449304614

More Books

Students also viewed these Databases questions

Question

=+4. Who are credible sources and opinion leaders for this public?

Answered: 1 week ago

Question

Explain Coulomb's law with an example

Answered: 1 week ago

Question

What is operating system?

Answered: 1 week ago

Question

What is Ohm's law and also tell about Snell's law?

Answered: 1 week ago