Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Either use the Java project from the first coding exercise, or create a new one, as you prefer. Create a new Java class named

image text in transcribed

1. Either use the Java project from the first coding exercise, or create a new one, as you prefer. Create a new Java class named computePay Put a heading on it similar to what you did for the other coding assignments and programming assignments. 2. Three companies need cargo shipped. Each pays a different amount to the truck driver who will deliver the cargo. Shipping company 1 (we'll get to names later in the quarter) pays $200 per day and $0.20 per mile (20 cents) driven. Company 2 pays a flat $300 per day. And company 3 pays $100 per day and $0.35 per mile (35 cents). 3. There are some basic rules: The driver has to be paid for a full day even if they only need part of one. So, if it will take them 3.4 days to make a delivery, they get paid for 4 full days. 4. Drivers can only drive 11 hours per day (not in practice, but let's keep things simple). At an average of 60 miles per hour, we will assume that a driver can drive 660 miles per day. 5. Create a method public static double truckerPay(int shipper, double miles) that computes the pay for the trucker depending on the shipper being used and the miles driven. Your method MUST use a switch construct in a meaningful way to compute the pay. 6. Recall from the first Programming Assignment that the round up function in Java is Math.ceil(). You'll need this when you figure out the number of days the trucker will be paid for. 7. Determine which company will pay the most money. This will, of course, change based on the miles, so your program should figure out which will pay the most. 8. Call your method on a set of test values. Use the same distance for each trucking company so that you can compare the results. Display the results of your calculations as: Company 1 will pay the trucker $PAY to transport the cargo DISTANCE. Company 2 will pay the trucker $PAY to transport the cargo DISTANCE. Company 3 will pay the trucker $PAY to transport the cargo DISTANCE. The trucker will get the most money from Company X. Of course, here PAY should get replaced with the actual pay, DISTANCE with the actual distance, and X with the appropriate company number

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions