fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.lang.Math; // headers MUST be above the first class
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone {
  7. public static void main (String[] args) throws java.lang.Exception {
  8. Account myAccount = new Account();
  9. Account yourAccount = new Account();
  10. myAccount.name = "Барри";
  11. myAccount.address = "222 Inner Lane";
  12. myAccount.balance = 24.02;
  13. yourAccount.name = "Джейн";
  14. yourAccount.address = "121 Outer Street";
  15. yourAccount.balance = 55.63;
  16. myAccount.display();
  17. System.out.print(" плюс $");
  18. System.out.print(myAccount.getInterest(5.00));
  19. System.out.println(" дохода ");
  20. yourAccount.display() ;
  21. double yourlnterestRate = 7.00;
  22. System.out.print(" плюс $");
  23. double yourlnterestAmount = yourAccount.getInterest(yourlnterestRate);
  24. System.out.print(yourlnterestAmount);
  25. System.out.println(" дохода ");
  26. }
  27. }
  28.  
  29. class Account {
  30. String name;
  31. String address;
  32. double balance;
  33. public void display() {
  34. System.out.print(name);
  35. System.out.print(" (");
  36. System.out.print(address);
  37. System.out.print(") has $");
  38. System.out.print(balance);
  39. }
  40. public double getInterest(double percentageRate) {
  41. return balance * percentageRate / 100.00;
  42. }
  43. }
Success #stdin #stdout 0.04s 4575232KB
stdin
Standard input is empty
stdout
Барри (222 Inner Lane) has $24.02 плюс $1.2009999999999998 дохода 
Джейн (121 Outer Street) has $55.63 плюс $3.8941000000000003 дохода