Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TransportPrice {
- public static void main(String []args){
- Scanner scanner = new Scanner(System.in);
- int distance = Integer.parseInt(scanner.nextLine());
- String dayOrNight = scanner.nextLine();
- Double price = 0.0;
- if (distance >= 100) {
- price = 0.06 * distance; //travel with train
- } else if (distance >= 20 && distance < 100) {
- price = 0.09 * distance; //travel with bus
- }
- if (distance < 20 ){ // travel with taxi
- if (dayOrNight.equals("day")){
- price = (distance * 0.79) + 0.70; // day rate
- } else if (dayOrNight.equals("night")){
- price = (distance * 0.90) + 0.70; // night rate
- }
- }
- System.out.printf("%.2f", price);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement