Advertisement
StefanTobler

Lesson 6 Activity 2

Sep 11th, 2016
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. /*
  2.  * Lesson 6 Coding Activity Question 2
  3.  *
  4.  * Input a double value and print only the integer part.
  5.  *
  6.  * Sample run:
  7.  
  8. Please input a decimal number:
  9. 57.8934
  10. Answer: 57
  11.  
  12. */
  13.  
  14. import java.util.Scanner;
  15. import java.lang.Math;
  16.  
  17. class Lesson_6_Activity_Two {
  18.     public static void main(String[] args) {
  19.      
  20.       Scanner scan = new Scanner(System.in);
  21.       System.out.println("Please input a decimal number: ");
  22.       double x = scan.nextDouble();
  23.       System.out.println("Answer: " + ((int)x));
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement