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

JAVA HELP Create a computer program that will calculate the range for 3 differen

ID: 3690636 • Letter: J

Question

JAVA HELP

Create a computer program that will calculate the range for 3 different vehicles.

The program should create a “programmer created” class, where 3 int objects are created passengers, fuel capacity, mpg.

Create a void() method inside the “programmer created “ class to calculate vehicle range.

range = fuel capacity * miles per gallon.

Each Vehicle type should have unique values for number of passengers, fuel capacity, and miles per gallon.

Follow the sample below and print information on 3 vehicle types.

Sample Output: // Create similar output for 3 Vehicle Types

The minivan carries= 7

The minivan has a fuel capacity of = 16

The minivan mpg = 21

The minivan has a range of: 336 miles

Explanation / Answer

class vehical_range
{
   int passengers, fuelcap, mpg;

   vehical_range(int p, int f, int m)
   {
       passengers=p;
       fuelcap=f;  
       mpg=m;
   }

   void range()
   {
       int range=fuelcap*mpg;
       if(passengers==7)
       {
           System.out.println("The Minivan carries="+passengers);
           System.out.println("The Minivan has a fuel capacity of ="+fuelcap);
           System.out.println("The Minivan mpg="+mpg);
           System.out.println("The Minivan range of: "+range+" miles");
       }

       if(passengers==9)
       {
           System.out.println("The van carries="+passengers);
           System.out.println("The van has a fuel capacity of ="+fuelcap);
           System.out.println("The van mpg="+mpg);
           System.out.println("The van range of: "+range+" miles");
       }

       if(passengers==11)
       {
           System.out.println("The Largevan carries="+passengers);
           System.out.println("The Largevan has a fuel capacity of ="+fuelcap);
           System.out.println("The Largevan mpg="+mpg);
           System.out.println("The Largevan range of: "+range+" miles");
       }
   }
}

class vehical_rangetest
{

   public static void main(String args[])
   {
      
       vehical_range o= new vehical_range(7,12,19);
       o.range();

       vehical_range o1= new vehical_range(9,15,17);
       o1.range();

       vehical_range o2= new vehical_range(11,17,22);
       o2.range();
   }
}