Hello everyone! I am new to Java so this may be a very easy question.
I am trying to write a program and display just the remainder after two numbers have been divided. Here is where i am:
import java.util.Scanner;
public class Midterm1
{
public static void main( String[] args )
{
Scanner input = new Scanner( System.in );// starts scanner
int input1;// user inputed number 1
int input2;// user inputed number 2
int answer;
System.out.print( "Enter input1: "); //prompt
input1 = input.nextInt(); // read number from user
System.out.print( "Enter input2: "); //prompt
input2 = input.nextInt(); // read number from user
answer = input1 % input2;
if( input1 % input2 == 0)
System.out.println( "No Remainder" );
if( input1 % input2 != 0)
System.out.printf( "%s%d\n", "The Remainder is:", answer);
}
}
For some reason instead of displaying the remainder it is displaying "input1".
Thank you for you help!