Sadia Mehrose_INFO6066 Project One - Lifeboats F2023

docx

School

Fanshawe College *

*We aren’t endorsed by this school

Course

1021

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

5

Uploaded by sadia.meh1234

Report
Course: INFO-6066 Coding for Test Project: Project #1 – Lifeboats Due Date: Oct. 14 th , 2023 at 11:59 pm Submitting: Please see the last page for instructions. Professor: Shelley Lapkowski Student Name: Sadia Mehrose Islam___________________ Student ID#: __1187398_______________________ How will my project be marked? If the program fails to compile, a Mark of 0 will be entered. This project accounts for 10% of your final mark and will be marked as follows: Marks Available What are the Marks Awarded For? Mark Assigned If the program fails to compile, a mark of 0 will be entered. 2 Correctly typed variables are created with good descriptive names to hold the input data 2 User is prompted to enter data and data is successfully read from the keyboard and assigned to the variables 2 Calculation of number of lifeboats needed is correct in all cases 2 Calculations of the number of people rescued and drowned are correct 2 Calculation of number of any additional spaces (extra capacity) is correct and only displayed if the number of people drowned is zero 2 Results are neatly displayed to the user and are complete 1 Program documentation header is present and complete 2 Good coding style including proper indentation and suitable comments 15 Total Fanshawe College Page 1 of 5 INFO-6066
Problem Description: Read Carefully When the Titanic embarked on her maiden voyage on April 10, 1912 there were 2,227 people on board. There were also only 20 lifeboats with an average capacity of about 59 people (maximum capacity was therefore about 20 x 59 = 1,180 people). Obviously it would have been ideal to have enough lifeboats to safely evacuate everyone on board ship! Your task is to write a Java program that will calculate the minimum number of lifeboats required to do this as well as the numbers of people who would be rescued or drowned given the number of available lifeboats. Your program should be flexible enough to work for any ship and size of lifeboat. Specifications: Write a Java program called Lifeboats.java that will do all of the following: 1. Display a title 2. Ask the user to enter the following values: a. The name of the ship (possibly including spaces like HMS Endurance ) b. The number of people on board the ship c. The maximum number of people that can be carried by one lifeboat assuming all the lifeboats on the ship are the same size d. The actual number of lifeboats that are available on board the ship 3. Calculate and display the following results: a. The minimum number of lifeboats required to carry all the people b. The number of people that would be rescued if the available lifeboats were filled (but not beyond the number of people on board the ship) as well as the percentage that this represents of all the people on board c. The number of people that would drown as well as the percentage that this represents of all the people on board d. If nobody drowns, then also display the number of additional people that could be carried by the lifeboats if they were all filled to capacity regardless of whether this number is greater than the number of people on board. Fanshawe College Page 2 of 5 INFO-6066
Sample Output and Calculations : Example 1: If there are 800 people, and each lifeboat can carry 90 people, then we need 9 lifeboats. With 9 lifeboats up to 9 x 90 = 810 people can be carried. Note that 8 lifeboats can only carry 720 people which is not enough! If there are 7 lifeboats available then only 7 x 90 = 630 people will be rescued (100 x 630 / 800 = 78.75%). This means 800 – 630 = 170 people will drown (100 x 170 / 800 = 21.25%). Example 2: If there are 800 people, and each lifeboat can carry 100 people, then we need 8 lifeboats. With 8 lifeboats up to 8 x 100 = 800 people can be rescued. If there are 9 lifeboats available then 9 x 100 = 900 people could be rescued, but there are only 800 people so only 800 will be saved (100%) and nobody drowns (0%). With 9 lifeboats the excess capacity would be 900 – 800 = 100 additional people. Fanshawe College Page 3 of 5 INFO-6066
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Points for consideration: 1. Solve each part of the problem separately. Make one functionality work, then another, and another. Don’t create new code until you have all existing code completely working. 2. Ideas for steps: a. First do a sample calculation or two on paper. b. Use your sample calculation(s) to do some “algorithmic thinking” (task decomposition) before you start coding. Spend a few minutes and just jot down on paper what steps need to be done, and in what order, for a solution to be generated. What inputs do you need to get from the user? How will you store these inputs? What data types will you use for your variables? You can then use this pseudo code as comments in your program. Some pseudo code has been provided in this document but you may need to add more detail and adapt it so that it makes complete sense to you! c. Get the user input working so that all the variables needed for the calculations are properly initialized. d. Add one calculation at a time to your program displaying the calculated value on the screen to verify its correctness before continuing. Don’t be afraid to declare extra variables to contain intermediate values such as the total number of people that could be rescued if all the lifeboats were filled to capacity. It can help to break your program down into smaller steps that you can more easily understand. e. Test your code using different inputs to make sure it works. You should include inputs that represent each of the following scenarios: i. There aren’t enough lifeboats to rescue everyone on board ii. There are exactly enough lifeboats to rescue everyone without any additional capacity iii. There is more than enough capacity on the lifeboats to rescue everyone f. Once all your calculations are working you can “fine-tune” your output to ensure its completeness and to make it looks nice. 3. Remember the naming conventions for variables that we discussed in class, and how we indent code blocks to improve the readability of the code. Use these conventions as you write your code. 4. Your program should have a documentation header (a series of comment lines at the top of the file) that lists the following information: Name of Program File: Lifeboats.java Author: A. Student Date: May 29, 2017 08:15 AM Description: A 2 or 3 line description of what the program is supposed to do. Fanshawe College Page 4 of 5 INFO-6066
How should I submit my project? Electronic Submission (mandatory ): Submit your source code “Lifeboats.java” to the Project 1 dropbox in FanshaweOnline . Hardcopy Submission (mandatory ): IN ADDITION to the Electronic Submission described above, submit the first page of this document (marking key) and a print-out of all your source code , STAPLED TOGETHER, in class ON OR BEFORE THE DUE DATE. Feedback will be written on the print-out and returned to you to give you a clearer idea of how to correct any errors. Make sure to write your name and student number on the first page. Submit your project on time! Both electronic and hardcopy submissions must be made on time! Late projects will be subject to divisional policy on missed test and late projects. Submit your own work and keep it to yourself ! It is considered cheating to submit work done by another student or from another source. Helping another student cheat by sharing your work with them is also not tolerated. Students are encouraged to share ideas and to work together on practice exercises, but any code or documentation prepared for a project must be done by the individual student. Penalties for cheating or helping another student cheat may include being assigned zero on the project with even more severe penalties if you are caught cheating more than once. Just submit your own work and benefit from having made the effort on your own. Fanshawe College Page 5 of 5 INFO-6066