Search code examples
javapojo

Simple Java calculation


Firstly sorry for the default question title I'm not sure how to go about giving this a good title.

The assignment is below and Ive complete the majority of it.

I've been tasked with an assignment from uni and Im having some trouble with one of the criteria.

You are a Junior Software Developer employed by NE Soft (NES) who have recently been approached by an agricultural engineering company named Tegg. Tegg specialise in building fertiliser spreaders for farmers. To promote their new XT55 model they would like you to create a Java Application that the farmer is able to use in order to determine the appropriate settings for their fields. This will allow the farmer to quickly find out the settings rather than having to use charts to work them out.

A fertiliser spreader is attached to the back of the tractor and filled with granular fertiliser usually from 600kg bags of which the XT55 is able to hold 2 600kg bags. The farmer has to decide how much fertiliser to spread to the acre/hectare in either Kilograms (kg) or hundred weights. Then they must decide how fast they are going to travel in miles per hour (mph) or kilometres per hour (kph). After this is done the farmer would change the setting on the spreader to the specified millimetre setting.

Based on the table the calculation is

if(mph == 5.5 || mph == 8.8){
    mph = 7.0;
    Double answer = mph * 5 + (0.4 * kg) -10; // CALCULATION
    resultLabel.setText(answer.toString());
}

This works as expected the criteria i am having difficulty with is part 4.

Allow the user to input the field size they are going to cover and calculate the amount of fertiliser in kg or hundred weights it will take to complete.

I'm not sure how I would lay out the calculation for this.

Please help.


Solution

  • You can input the field size (1) and you know already how much fertiliser is required per acre/hectare (2).

    So shouldn't it be (1)/(2)