Guest User

Untitled

a guest
Aug 17th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. Valriable might not have been initialized?
  2. import static javax.swing.JOptionPane.*;
  3. import java.text.DecimalFormat;
  4.  
  5. class Question3 {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. String intrestRateStr = showInputDialog("What is the interest rate?");
  10. int intrestRate = Integer.parseInt(intrestRateStr);
  11.  
  12. String depositStr = showInputDialog("How much will you deposit?");
  13. double depositAmount = Double.parseDouble(depositStr);
  14.  
  15. DecimalFormat pounds = new DecimalFormat("£###,##0.00");
  16.  
  17. double amountInterest = calcAmount(intrestRate, depositAmount);
  18.  
  19. String bonusStr;
  20. double bonus = Double.parseDouble(bonusStr);
  21.  
  22. if (amountInterest >= 5000.00)
  23. bonus = (+100.00);
  24. else if (amountInterest >= 1000.00)
  25. bonus = (+50.00);
  26.  
  27.  
  28. double finalAmountInterestBonus = bonus + amountInterest;
  29.  
  30. showMessageDialog(null,
  31. "Your savings will become " + pounds.format(finalAmountInterestBonus));
  32. }
  33.  
  34. private static double calcAmount(int intRate, double depAmount) {
  35. double result = depAmount*(1.0 + intRate/100.0);
  36. return result;
  37. }
  38. }
  39.  
  40. String bonusStr;
  41. double bonus = Double.parseDouble(bonusStr);
  42.  
  43. String bonusStr = "123.456";
  44. double bonus = Double.parseDouble(bonusStr);
  45.  
  46. String bonusStr;
  47. double bonus = Double.parseDouble(bonusStr);
  48.  
  49. String bonusStr;
  50. double bonus = Double.parseDouble(bonusStr);
  51.  
  52. String bonusStr = "0";
Add Comment
Please, Sign In to add comment