我需要编写一个包含以下内容的代码在此项目中,您将编写一个程序,允许用户重复创建和管理快速卡帐户。
每张快递卡都像借记卡一样,但它只能用于购买餐点。新的快速卡帐户余额为0美元。用户可以
有两种类型的快递卡帐户:
所有快递帐户都有字段,accountBalance,numberOfMeals,pricePerMeal和baseAmtForBonus。
到目前为止,我有,我不知道从哪里开始import java.util.Scanner;
public class ExpAcct{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("MAIN MENU /n 1.) Create a new account /n 2.) Log into an existing account /n3.) Exit the banking system /nPlease enter your selection.");
int main = scan.nextInt();
System.out.println("CHOOSE THE TYPE FOR THE NEW ACCOUNT /n1.) Student express account /n2.)Faculty express account /nPlease enter your selection");
int accType = scan.nextInt();
}
public class ExpressAccount extends ExpAcct{
public ExpressAccount(int accNumber){
}
public int getAccountNumber(){
return accNumber;
}
public double getAccountBalance(){
return accBalance;
}
public double getBaseAmtForBonus(){
return baseAmt;
}
public double getPricePerMeal(){
return pricePerMeal;
}
public int getNumOfMeals(){
return numMeals;
}
public String toString(){
}
答案 0 :(得分:1)
您要做的是通过执行此操作来检查用户输入的内容:
if(main==1){
if(accType==1){
String accTypeWord = "Student";
if(accType==2){
String accTypeWord = "Faculty";
}
if(main==2){
System.out.println("Please enter your password: ");
//check if password equals their account password
}
if(main==3){
System.out.println("Have a good day! Thanks for visiting the bank.");
}
如果您想为他们购买一顿饭付钱,可以试试这个:
Scanner scanner = new Scanner(System.in);
System.out.println("How much do you have in your ATM account? ");
double accountBalance = scanner.nextInt();
System.out.println("Please enter cost of meal: ");
double mealCost = scanner.nextInt();
int accountBalance -= mealCost
这将使您的银行存款金额减少一餐费用。你可能不希望他们在他们的帐户中有多少,但我必须在这里告诉你如何做到这一点。
以下是您的计划中需要的步骤:
祝你好运,快乐的编码!