Question: Write an application that reads two integers, determines whether the first is a multiple of the second and prints the result. [Hint: Use the remainder operator.]

/** * * @Author: Aghatise Osazuwa * Website: www.cscprogrammingtutorials.com * * Exercise 2.26 - Multiples * This Program Determines Whether The First Number Is A Multiple Of The Second Number * */ import java.util.Scanner; public class Ex02_26 { public static void main (String [] args) { Scanner numbers = new Scanner (System.in); int num1; int num2; int check; System.out.print ("Enter First Number: "); num1 = numbers.nextInt(); System.out.print ("Enter Second Number: "); num2 = numbers.nextInt(); check = num2%num1; System.out.println (); if (check == 0) System.out.printf ("The Number %d is a multiple of %d", num1, num2); else System.out.printf ("The Number %d is not a multiple of %d", num1, num2); } }

Thanks Dear

ReplyDeleteshould be check = num1%num2;

ReplyDeleteor change num params in printf functions