Assignment #117 More Number Puzzles
Code
///Name: Ian Grant
///Period:5
///Project Name: More Number Puzzles
///File Name:NumPuzz4.java
///05/25/16
import java.util.Scanner;
class NumPuzz4
{
public static void main (String [] args)
{
Scanner stuff = new Scanner(System.in);
int a;
do
{
System.out.println("1) Find two diget number <= 56 with sum > 10");
System.out.println("2) Find to diget number minus number reversed which equals sum of digets.");
System.out.println("3) Quit");
a = stuff.nextInt();
if (a == 1)
{
math();
}
else if (a == 2)
{
ma();
}
}while (a < 3);
}
public static void math()
{
int c = 10;
for (int x = 1; x < 6; x++)
{
for (int y = 0; y < 10; y++)
{
if (c < 57 && (x + y) > 10)
{
System.out.println(c);
}
c++;
}
}
}
public static void ma()
{
int z = 10;
for (int a = 1; a < 10; a++)
{
for (int b = 0; b < 10; b++)
{
int inv = (b*10)+a;
int sum = a + b;
if (z - inv == sum)
{
System.out.println(z);
}
z++;
}
}
}
}
Output