-3
ユーザが4桁の数字を入力し、6桁の数字を入力するプログラムを作成しようとしています。最初の4桁は、5桁目が(digit1 + digit2 + digit4)%10)であり、6桁目が3桁目の間にユーザが入力したものです。ここまで私がこれまで持っていたことがあります。ユーザー入力のクラスが提供されています。どんな助けもありがとうございます。Javaで複数のクラスを使用してプログラムを作成する際の問題
import java.lang.Math;
/**
* Purpose: This class/program generates a 6 digit card number based on 4 digits inputed by the user
*/
public class CardGenerator
{
public void main(String[] args)
{
UserInteraction input = new UserInteraction();
calculateDigit5 digit5Calc = new calculateDigit5();
getDigit digit = new getDigit();
getRemainder remainder = new getRemainder();
int number = input.getIntValueFromUser("Enter the four digit card number"),
digit1 = getDigit(number, 3),
number = getRemainder(number, 3),
digit2 = getDigit(number, 2),
number = getRemainder(number, 2),
digit3 = getDigit(number, 1),
number = getRemainder(number, 1),
digit4 = getDigit(number, 0),
digit5 = calculateDigit5,
digit6 = digit3;
System.out.println("The 6 digit card number is " + digit1 + digit2 + digit3 + digit4 + digit5
+ digit6);
}
public class getDigit
{
int digitWeight = Math.pow(number, (1/1000)),
rem = getRemainder(number, digitPosition),
digit = (originalNumber - rem)/digitWeight;
}
public class getRamainder
{
}
public class calculateDigit5
{
int digit5 = (digit1 + digit2 + digit4) % 10;
}
}
これはこれは、あなたが始めるのは十分以上である必要があり、私に
import java.util.*;
//DO NOT PUT OTHER METHODS IN THIS CLASS or make any changes to it
public class UserInteraction
{
public String getStringValueFromUser(String message)
{
String value = "";
Scanner input = new Scanner(System.in);
System.out.print(message + " : ");
value = input.nextLine();
return value;
}
//DO NOT PUT OTHER METHODS IN THIS CLASS or make any changes to it
public double getDoubleValueFromUser(String message)
{
double value = 0;
Scanner input = new Scanner(System.in);
System.out.print(message + " : ");
value = input.nextDouble();
return value;
}
//DO NOT PUT OTHER METHODS IN THIS CLASS or make any changes to it
public int getIntValueFromUser(String message)
{
int value = 0;
Scanner input = new Scanner(System.in);
System.out.print(message + " : ");
value = input.nextInt();
return value;
}
//DO NOT PUT OTHER METHODS IN THIS CLASS or make any changes to it
}