fork download
  1. import java.util.*;
  2.  
  3. public class Kadai1104 {
  4. public static void main(String[] args) {
  5. BankBase[] bbs = new BankBase[5];
  6. Scanner sc = new Scanner(System.in);
  7. System.out.println("入金日(年)の入力");
  8. System.out.print("年: ");
  9. int startYear = sc.nextInt();
  10. for(int i=0; i<bbs.length; i++) {
  11. System.out.print("預金タイプ(普通=1 / 定期=2): ");
  12. int num = sc.nextInt();
  13. System.out.print("入金額: ");
  14. int money = sc.nextInt();
  15. if(num == 1) {
  16. bbs[i] = new FBank(money);
  17. }
  18. else if(num == 2) {
  19. System.out.print("満期年数(1 / 3 / 5): ");
  20. int due = sc.nextInt();
  21. bbs[i] = new TBank(money, due);
  22. }
  23. bbs[i].setStartYear(startYear);
  24. }
  25. FBank.setRate(3.0);
  26. System.out.println("普通利息を" + FBank.getRate() + "%にセット");
  27. TBank.setRate(5.0);
  28. System.out.println("定期利息を" + TBank.getRate() + "%にセット");
  29.  
  30. System.out.println("現在の普通利率は" + FBank.getRate() + "%です");
  31. System.out.println("現在の定期利率は" + TBank.getRate() + "%です");
  32.  
  33. System.out.println("本日の日付(年)の入力");
  34. System.out.print("年: ");
  35. int Year = sc.nextInt();
  36. BankBase.setCurrentYear(Year);
  37.  
  38. for(int i=0; i<bbs.length; i++) {
  39. System.out.print("口座番号: " + bbs[i].getAccountNum() + " 預金額: ");
  40. bbs[i].addInterest();
  41. }
  42. }
  43. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty