Advertisement
Dilyana86

Untitled

Apr 13th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public interface bookProblem260415morning {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int pages = Integer.parseInt(scan.nextLine());
  7.         int campDays = Integer.parseInt(scan.nextLine());
  8.         int readNormal = Integer.parseInt(scan.nextLine());
  9.  
  10.         if (campDays == 30 || readNormal == 0){
  11.             System.out.println("never");
  12.             return;
  13.         }
  14.         int readDays = 30 - campDays;
  15.         int readPages = readDays * readNormal;
  16.         int totalMonth = (int)Math.ceil(pages / readPages);
  17.         int years = totalMonth / 12;
  18.         int months = totalMonth % 12;
  19.         System.out.printf("%d years %d months",years,months);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement