Advertisement
jinglis

Calculator Page Service.

Jul 28th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. /* Name: James Inglis
  2.  * Syntax: Java
  3.  * Date: 7/28/14
  4.  * Description: Just decided to grab a random algorithm and implement it
  5.  *              in code.
  6.  */
  7.  
  8.  
  9.  
  10. import java.util.*;
  11.  
  12. public class Num5
  13. {
  14.    static Scanner console = new Scanner(System.in);
  15.    static final double SERVICE = 3.00;
  16.    static final double PER_PAGE = 0.20;
  17.    static final double ADD_PER_PAGE = 0.10;
  18.    public static void main(String[] args)
  19.    {
  20.       int pages; // Stores the number of pages.
  21.       double total; // Totaling the amount that's suppose to be paid.
  22.      
  23.      
  24.       // Getting the pages.
  25.       System.out.print("Enter in the number of fax pages: ");
  26.       pages = console.nextInt();
  27.       System.out.println();
  28.      
  29.       // If pages are less than 10.
  30.       if (pages <= 10)
  31.       {
  32.          total = (pages * PER_PAGE) + SERVICE;
  33.          System.out.printf("Total for pages: $%.2f", total);
  34.       }
  35.      
  36.       // If pages are greater than 10.
  37.       if (pages > 10)
  38.       {
  39.          total = SERVICE + 10 * PER_PAGE + (pages - ADD_PER_PAGE) * ADD_PER_PAGE;
  40.          System.out.printf("Total for pages: $%.2f", total);
  41.       }
  42.      
  43.    }
  44.    
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement