Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Homework Assignment 4 - Taxi
- --------------------------------------
- import java.util.Scanner;
- public class Taxi {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- final float initRate = 10.2f; // Setting the initial rate as a constant by defining it as 'final'
- float pricePerKM = 1.3f;
- int suitCaseRate = 2;
- float distance;
- int numOfCases;
- // Getting data from the user
- System.out.println("Please enter the distance to your destination: ");
- distance = s.nextFloat();
- System.out.println("Please enter the number of suitcases: ");
- numOfCases = s.nextInt();
- // Calculating the total cost and printing it to the console
- System.out.println("The total price for the ride is: " + (initRate + distance*pricePerKM + numOfCases*suitCaseRate));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement