Object Oriented Programming Task 1 In a bookstore, customers can choose to have their books sent to their address to avoid carrying them by themselves. The books will then be packed in boxes. Max 5...

1 answer below »
Hey,i would love help with solving the above task and i would love the source code to be well commented out to help me understand whats going on in the code. Thank you very much.


Object Oriented Programming Task 1 In a bookstore, customers can choose to have their books sent to their address to avoid carrying them by themselves. The books will then be packed in boxes. Max 5 books per box. Write an application for the bookstore. The application should ask the user to enter the number of books they want to be shipped and then the program should calculate how many boxes that are needed as well as number of books in each box. The main rule is that, if possible, the boxes must be packed full (with the maximum number of books). The application must then calculate the shipping fee and display the sum on the console window. Shipping fee for an order of 1-5 boxes is 8 SEK / box. When ordering 6-50 boxes, the shipping fee is 5 SEK / box. It should not be possible to order less than one book. In this case, a message should be printed asking the user to try again and it should be possible to try again without needing to run the program again. The application shall be robust and user friendly so that customers feel comfortable using it. You need to write at least one method (In addition to the main method) for the calculations. Test the application with different inputs and check if it works properly. An example output of the application can be as follows: How many books do you have for shipping? -4 Not a valid number, try again. How many books do you have for shipping? abc Not a valid number, try again. How many books do you have for shipping? 8 You will receive 2 boxes, one box containing 5 books and one box containing 3 books. The shipping price will be: 16 SEK Task 2 Your program should prompt the user for a number of integers, calculate the minimum number and display the result in the console window as soon as the user enters the number 0. Here you can see an output example to such an application. It is always good to give the user some information in the beginning of each application about how the application works, which is missing here in this output example. Example of output: Write a number: 20 Write another number: 45 Write another number: 7 Write another number: 0 The minimum number that you have entered was: 7 Task 3 Write a program that calculates the remaining travel time if you know the average speed in km / h and the remaining mileage in miles. You can assume that the average speed is the same throughout the remaining mileage. (You can use Math.round() to round a double value). The result shall look like the following example: Enter the average speed : 120 Enter the remaining mileage : 20 Your remaining travel time is: 1 hour(s) and 40 minutes.
Answered Same DayNov 07, 2021

Answer To: Object Oriented Programming Task 1 In a bookstore, customers can choose to have their books sent to...

Sayed Shad Ahmad answered on Nov 07 2021
137 Votes
Solution/Task1.java
Solution/Task1.java
//Importing Scanner class for user input
import java.util.Scanner;
//Class Task1
public class Task1
{
    //Method to calculate shipping price for given number of boxes
    public static int calcShipPrice
(int box)
    {
        //Declaring variable to store shipping price
        int price;

        /*
         * Calculating shipping price 
         */
        if(box <= 5)
            price = 8 * box;
        else
            price = 5 * box;

        //Returning shipping price
        return price;
    }

    //main method
    public static void main(String[] args) 
    {
        //Creating Scanner object for user input
        Scanner sc = new Scanner(System.in);

        //Declaring constant for maximum number of books per box
        final int max = 5;

        //Declaring variable to store data entered by user
        String data;

        //Declaring variable to store number of books & boxes required
        int books, boxes;

        //Declaring variable to store number of full boxes required & books in partially filled box
        int fullBoxes, partialBox;

        //Declaring an array to store name of numbers
        String numberNames[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
                                "eleven", "twelve", "thirteen", "fourteen", "fifteen",
                                "sixteen", "seventeen", "eighteen", "nineteen", "twenty",
                                "twenty-one", "twenty-two", "twenty-three", "twenty-four", "twenty-five",
                                "twenty-six", "twenty-seven", "twenty-eight", "twenty-nine", "thirty",
                                "thirty-one", "thirty-two", "thirty-three", "thirty-four", "thirty-five",
                                "thirty-six", "thirty-seven", "thirty-eight", "thirty-nine", "forty",
                                "forty-one", "forty-two", "forty-three", "forty-four", "forty-five",
                                "forty-six", "forty-seven", "forty-eight", "forty-nine", "fifty" };

        //Repeating until user enters valid number of books
        do
        {
            //Requesting number of books from user
            System.out.println("How many books do you have for shipping?");
            data = sc.nextLine();
 
            //try block
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here