我需要能够输入两个数字,将第一个除以第二个并输出它输入的次数以及余数是多少。
我可以打印出余数,但我如何计算出这个数字除以多少次?我的代码如下
import java.util.Scanner;
public class TotalAndRemainder
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter your first number");
int firstvalue = keyboard.nextInt();
System.out.println("Enter your second number");
int secondvalue = keyboard.nextInt();
int total = firstvalue / secondvalue;
int remainder = firstvalue % secondvalue;
System.out.println("The remainder is " + remainder);
}
}