Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class test {
  6.     public static void main(String[] args) {
  7.         Scanner input = new Scanner(System.in);
  8.  
  9.         int distance = input.nextInt();
  10.         String time = input.next();
  11.  
  12.         double total = 0.00;
  13.         if (distance > 0 && distance < 20) {
  14.             if (time.equals("day")) {
  15.                 total = 0.7 + 0.79 * distance;
  16.             } else if (time.equals("night")) {
  17.                 total = 0.7 + 0.9 * distance;
  18.             }
  19.         }
  20.         else if (distance >= 20) {
  21.             total = distance * 0.09;
  22.         } else if (distance >= 100) {
  23.             total = distance * 0.06;
  24.         }
  25.         System.out.printf("%.2f", total);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement