Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you type it please? Before reading this assignment, remember that the Guide to Mini Projects is ALWAYS part of the instructions for EVERY Mini

can you type it please? image text in transcribed
image text in transcribed
Before reading this assignment, remember that the Guide to Mini Projects is ALWAYS part of the instructions for EVERY Mini Project Assignment. Please go back and read it before beginning. Mini Project #2-Bus Routes Introduction You are working for a city, and want to set up a system for better understanding the needs of the busses running on certain routes. Using demographic data and technical specifications of busses, the city has created data structures for each city bus with the following properties that do not change: bus.mass- The mass of the buss bus.passMass -The average mass of a passenger on a route bus.engine-The amount of force the bus's engine puts out per unit mass In addition, you have added the following property to the structure for simulation purposes. This property can change: bus.numPass-The number of passengers on the bus. Procedure The city wants you to do some calculations on the amount of work buses have to do on bus routes, given the number of passengers entering and leaving busses. You will write a function called bussim that will take the following inputs bus - A structure with the format defined above. You can assume that it will start with a certain number of passengers on board passon- An array that contains only integers. This is the number of passengers that get on at each stop. passot -An armay that contains only integers and is the same length as pasaon. This is the number of passengers that get off at each stop. distance-An array that contains real numbers that is the same length as passon containing the distance the bus has to travel after each bus stop to get to the next stop. It should return the following ouputs: bus -An updated version of the input structure with the final number of passengers. passRecord -An array with the same length ad passon with the number of passengers after each bus stop. totalWork-A real number that is the total amount of work the bus's engine has had to put out on th entire trip. You can assume that passengers will board and leave the bus at the first ston before It should return the following ouputs bus - An updated version of the input structure with the final number of passengers passRecord -An array with the same length ad passon with the number of passengers after each bus stop totalWork - A real number that is the total amount of work the bus's engine has had to put out on the entire trip. You can assume that passengers will board and leave the bus at the first stop before you have to make the first work calculation. You should therefore make as many work calculations as there are elements in each of the input arrays. Additional Code -Data Entry Errors Your function should work with any inputs that are of the correct input data types, even if they contain errors. You should handle those errors in the following ways If your input arrays are not all the same length you should only do calculations up to the index of the shortest array. If the number of passengers would ever go below 0, it should instead be set to 0. If the number of passengers would ever be a non-integer value, it should instead be rounded up to the nearest integer If a distance is listed as negative, treat it as positive - You can assume the following and do not have to check for them Masses will always be positive Engines will always put out positive force The numbers in passon or passOff will always be non-tegative Before reading this assignment, remember that the Guide to Mini Projects is ALWAYS part of the instructions for EVERY Mini Project Assignment. Please go back and read it before beginning. Mini Project #2-Bus Routes Introduction You are working for a city, and want to set up a system for better understanding the needs of the busses running on certain routes. Using demographic data and technical specifications of busses, the city has created data structures for each city bus with the following properties that do not change: bus.mass- The mass of the buss bus.passMass -The average mass of a passenger on a route bus.engine-The amount of force the bus's engine puts out per unit mass In addition, you have added the following property to the structure for simulation purposes. This property can change: bus.numPass-The number of passengers on the bus. Procedure The city wants you to do some calculations on the amount of work buses have to do on bus routes, given the number of passengers entering and leaving busses. You will write a function called bussim that will take the following inputs bus - A structure with the format defined above. You can assume that it will start with a certain number of passengers on board passon- An array that contains only integers. This is the number of passengers that get on at each stop. passot -An armay that contains only integers and is the same length as pasaon. This is the number of passengers that get off at each stop. distance-An array that contains real numbers that is the same length as passon containing the distance the bus has to travel after each bus stop to get to the next stop. It should return the following ouputs: bus -An updated version of the input structure with the final number of passengers. passRecord -An array with the same length ad passon with the number of passengers after each bus stop. totalWork-A real number that is the total amount of work the bus's engine has had to put out on th entire trip. You can assume that passengers will board and leave the bus at the first ston before It should return the following ouputs bus - An updated version of the input structure with the final number of passengers passRecord -An array with the same length ad passon with the number of passengers after each bus stop totalWork - A real number that is the total amount of work the bus's engine has had to put out on the entire trip. You can assume that passengers will board and leave the bus at the first stop before you have to make the first work calculation. You should therefore make as many work calculations as there are elements in each of the input arrays. Additional Code -Data Entry Errors Your function should work with any inputs that are of the correct input data types, even if they contain errors. You should handle those errors in the following ways If your input arrays are not all the same length you should only do calculations up to the index of the shortest array. If the number of passengers would ever go below 0, it should instead be set to 0. If the number of passengers would ever be a non-integer value, it should instead be rounded up to the nearest integer If a distance is listed as negative, treat it as positive - You can assume the following and do not have to check for them Masses will always be positive Engines will always put out positive force The numbers in passon or passOff will always be non-tegative

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

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

=+ (c) Show that if & is countable, then f(. ) is countable.

Answered: 1 week ago