Using a Java.
2. Write a Java program calculate_fare.java to take the inputfor number of miles, and the class of journey (1,2, or 3, forfirst, second, and third class respectively), for a trainjourney.
The program should then calculate and display the fare ofjourney based on the following criteria:
Note: Use Switch...case and if...elseconstruct
| First (1) Class | Second (1) Class | Third (3) Class |
First 100 mile | $ 3 per mile | $ 2 per mile | $ 1.50 per mile |
Next 150 mile | $ 2.50 per mile | $ 1.50 per mile | $ 1 per mile |
Remaining | $ 2 per mile | $ 1 per mile | $ 0.50 per mile |
Rubric:
- Input, usage of appropriate data types - 2 points
- Appropriate usage of if...else in each case of switch constructfor each class of journey : 4 points
- Documentation and appropriate variable names- 2 points
The layout of  switch case should be as follows:
switch(cls)//class
{
    case 1: if construct for calculatingfare for class 1
    case 2: if construct for calculatingfare for class 2
    case 3: if construct for calculatingfare for class 3
    default: Display it is an invalidclass
}