hpilo

Chapter1_Ex3

Dec 15th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /*
  4.     ===============================================
  5.      NoteBook chapter 1: language building stones
  6.  
  7.                Ex3: Furniture Shipment
  8.     ===============================================
  9.  */
  10. public class MyProgram {
  11.     public static void main(String[] args) {
  12.  
  13.         //variables
  14.         final int SHIPMENT_PRICE=5;
  15.         final int FLOOR_PRICE=1;
  16.         final double TIP=0.1;
  17.         Scanner s=new Scanner(System.in);
  18.         int furniturePrice;
  19.         int wight,floor,distance;
  20.         double totalPrice;
  21.  
  22.         //user input
  23.         System.out.println("Enter furniture price: ");
  24.         furniturePrice=s.nextInt();
  25.         System.out.println("Furniture wight: ");
  26.         wight=s.nextInt();
  27.         System.out.println("Floor: ");
  28.         floor=s.nextInt();
  29.         System.out.println("Distance(km): ");
  30.         distance=s.nextInt();
  31.  
  32.         //calc total price to pay
  33.         totalPrice=(furniturePrice+(floor*wight*FLOOR_PRICE)+(SHIPMENT_PRICE*distance)+(furniturePrice*TIP));
  34.         System.out.println("total price: "+totalPrice);
  35.        
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment