Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Lesson 7 Coding Activity Question 1
- *
- * Input a positive three digit integer. Print out the digits one per line.
- *
- * Sample run:
- Please enter a three digit number:
- 678
- Here are the digits:
- 6
- 7
- 8
- */
- import java.util.Scanner;
- import java.lang.Math;
- import java.io.*;
- class Lesson_7_Activity_One {
- public static void main(String[] args) throws IOException {
- System.out.println("Please enter a three digit number:");
- Scanner scan= new Scanner(System.in);
- int x = scan.nextInt();
- int y = x/100;
- int z = (int)(x*.1)%10;
- int a = x%10;
- System.out.println("Here are the digits:\n" + y + "\n" + z + "\n" + a + "\n" + y + " + " + z + "+ " + a + "= " + (y + z + a));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement