Last active
August 24, 2018 13:04
-
-
Save Azure-Agst/3c1e7fd1d188769494abe00aea64c4f6 to your computer and use it in GitHub Desktop.
L7A1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.lang.*; | |
//lmao fuck modulus | |
public class Lesson_7_Activity_One { | |
public static void main(String []args){ | |
Scanner scanner = new Scanner(System.in); | |
System.out.println("Enter a three digit number:"); | |
String x = scanner.nextLine(); | |
char[] digits = x.toCharArray(); | |
if (digits.length == 1) { | |
System.out.println("Here are the digits:\n" + digits[0] + "\n0\n0"); | |
} else if (digits.length == 2) { | |
System.out.println("Here are the digits:\n" + digits[0] + "\n" + digits[1] + "\n0"); | |
} else if (digits.length == 3) { | |
System.out.println("Here are the digits:\n" + digits[0] + "\n" + digits[1] + "\n" + digits[2]); | |
} | |
} | |
} | |
public class Lesson_7_Activity_Two { | |
public static void main(String []args){ | |
Scanner scanner = new Scanner(System.in); | |
System.out.println("Enter a three digit number:"); | |
String x = scanner.nextLine(); | |
char[] digits = x.toCharArray(); | |
// int one = x%1000/100; | |
// int two = x%100/10; | |
// int three = x%10; | |
if (digits.length == 1) { | |
System.out.println("Here are the digits:\n0\n0\n" + digits[0]); | |
System.out.println("0 + 0 + "+digits[0]+" = "+digits[0]); | |
} else if (digits.length == 2) { | |
System.out.println("Here are the digits:\n" + digits[0] + "\n" + digits[1]); | |
System.out.println("0 + "+digits[0]+" + "+digits[1]+" = "+(Character.getNumericValue(digits[0])+Character.getNumericValue(digits[1]))); | |
} else if (digits.length == 3) { | |
System.out.println("Here are the digits:\n" + digits[0] + "\n" + digits[1] + "\n" + digits[2]); | |
System.out.println(digits[0]+" + "+digits[1]+" + "+digits[2]+" = "+(Character.getNumericValue(digits[0])+Character.getNumericValue(digits[1])+Character.getNumericValue(digits[2]))); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment