Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me. I am unable to use scanner class for this project. I am having t

ID: 3664247 • Letter: P

Question

Please help me. I am unable to use scanner class for this project. I am having trouble producing the input section of this question. Please help.

When searching for a sailboat to buy, potential buyers, use several ratios as "rules of thumb" to evaluate a candidate for suitability. The users get a bit tired of entering all the data and performing the calculations using a simple hand calculator. They have hired you to write a Java program to perform the calculations when they have entered the necessary data.

The following explainations for formulae may be helpful during the evaluation of a sailboat:

Maximum hull speed:

Hull Speed = 1.34 * LWL.5

This is the theoretical maximum speed of a displacement sailboat in knots (one that does not plane - a boat which is capable of planing may excape its hull speed).

D/L:

Tons may be calculated by dividing displacement in pounds by 2,240. This ratio helps the buyer to place the boat into a light, medium, and heavy displacement category. Boats less than 125 are considered ultra light-displacement, below 200 is a very light-displacement cruiser or a light-displacement racer, below 325 is a moderate-displacement cruiser/racer and anything greater than 325 is a heavy cruiser.

SA/D:

This ratio allows the buyer to compare the sail area of different boats with the assumption that the only limitation on boat speed is the displacement of the boat. In reality this is an oversimplification, since a poorly built light boat with gigantic sails might be much slower than a much heavier well constructed boat. However, it does provide a good ballpark estimation and is fairly widely used to indicate boat performance.

The next two ratios are pretty iffy (noone takes much stock in them), but they might yeild a bit more about the boat in question's characteristics.

CapI:

The larger the number, the less stable the boat, very wide, light boats will score lower on this index. The modern tendency is for boats to have a wide beam (more room to spread out below), also look at the very wide boats sailed in the Around the World Alone race this past year. Again in reality there is a lot more to the tendency of a boat to capsize (amount of ballast, location of ballast, type of keal, etc). Boat stability is a very complex matter (stability curves are published by US Sailing on most boats afloat in US waters today).

ComfI:

Of the various ratios this one is the most tenuous.. In many respects it seems to be the opposite of the CapI with the wider beam increasing the comfort. Oh well, it is just an excersize.

The program you are to write is to provide the input fields for the following input items:

LOA (total length for the vessel)

LWL (water line length for the vessel)

Beam (width for the vessel)

Displacement

Sail area

If the input to your program is:

Your program will be expected to output the following information:

LOA: 34.50

LWL: 24.00

Beam: 10.20

Displacement: 11200.00

Sail area: 483.00

Hull speed: 6.56

D/L: 361.69

SA/D: 15.17

Capsize index: 1.86

Comfort index: 28.91

If a calculation cannot be performed (ie: a divide by zero would occur) your program will print the name of the ratio and that it cannot be performed. ie: if Bill entered the following data:

LOA: 34.50

LWL: 24.00

Beam: 10.20

Displacement: 0.00

Sail area: 483.00

Your program will need to indicate that:

Hull speed: 6.56

D/L: 0.00

SA/D: Cannot be performed

Capsize index: Cannot be performed

Comfort index: 0.00

Explanation / Answer


// header files
import java.io.*;
import java.text.*;

// create class HelloWorld
public class HelloWorld {

   public static void main (String [] args) throws IOException {
  
   //asking input from user
   InputStreamReader reader = new InputStreamReader (System.in);
   BufferedReader stdin = new BufferedReader (reader);
  
   //number format which is displayed
   DecimalFormat floats = new DecimalFormat("#.##");

   String [] userInput;
   String quitQuery = "";

   // declare variables
   double LOA, LWL, Beam,Displacement,SailArea;

   // checking the system using while loop
   // enter Q or q to quit the program
   while (!quitQuery.equals ("Q")     &&     !quitQuery.equals ("q")) {

       System.out.println (" Enter in LOA, LWL, Beam Displacement and Sail Area - all separated by spaces. ");
           userInput = stdin.readLine ().split ("[\s]+");
          
           // getting input from user
           LOA = Double.parseDouble (userInput [0]);      
           LWL = Double.parseDouble (userInput [1]);      
           Beam = Double.parseDouble (userInput [2]);      
           Displacement = Double.parseDouble (userInput [3]);      
           SailArea = Double.parseDouble (userInput [4]);      
  


       // display the output
       System.out.println (" LOA : " + floats.format (LOA) +
                    " LWL : " + floats.format (LWL) +
                    " Beam : " + floats.format (Beam) +
                    " Displacement : " + floats.format (Displacement) +
                    " Sail Area : " + floats.format (SailArea) + " ");

       // checking the condition using if loop
       if (LWL >= 0)
           System.out.println ("Hull speed : " + floats.format(1.34 * Math.pow (LWL, .5)));
       else
           System.out.println ("Hull speed : Cannot be performed");

       if (LWL > 0)
           System.out.println ("D/L : " + floats.format((Displacement / 2240.0) / Math.pow (.01 * LWL, 3)));
       else
           System.out.println ("D/L : Cannot be performed");

       if (Displacement > 0)
       {
           System.out.println ("SA/D : " + floats.format(SailArea / Math.pow (Displacement / 64, .67)));
           System.out.println ("Capsize Index : " + floats.format(Beam / Math.pow (Displacement / 64, .33)));
       }

       else
       {
           System.out.println ("SA/D : Cannot be performed");
           System.out.println ("Capsize Index : Cannot be performed");
       }

       if (Beam > 0     &&     (.7 * LWL + .3 * LOA) != 0)
           System.out.println ("Comfort Index : " + floats.format(Displacement / (.65 * (.7 * LWL + .3 * LOA) * Math.pow (Beam, 1.33))));

       else
           System.out.println ("Comfort Index : Cannot be performed");

       // quit option
       System.out.print (" Enter "Q" or "q" to quit. Enter any other value to calculate values for another sail boat. ");
           quitQuery = stdin.readLine ();


       }        

   System.out.println ("Goodbye, sailor.");  
  
   }

}


output


Enter in LOA, LWL, Beam Displacement and Sail Area - all separated by spaces.                                                                                                                                                                                        
34.5 24.0 10.2 11200 483                                                                                                                                    
                                                                                                                                                            
LOA : 34.5                                                                                                                                                  
LWL : 24                                                                                                                                                    
Beam : 10.2                                                                                                                                                 
Displacement : 11200                                                                                                                                        
Sail Area : 483                                                                                                                                             
                                                                                                                                                            
Hull speed : 6.56                                                                                                                                           
D/L : 361.69                                                                                                                                                
SA/D : 15.17                                                                                                                                                
Capsize Index : 1.86                                                                                                                                        
Comfort Index : 28.91                                                                                                                                       
                                                                                                                                                            
Enter "Q" or "q" to quit. Enter any other value to calculate values for another sail boat.                                                                  


                                    

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote