Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Valriable might not have been initialized?
- import static javax.swing.JOptionPane.*;
- import java.text.DecimalFormat;
- class Question3 {
- public static void main(String[] args) {
- String intrestRateStr = showInputDialog("What is the interest rate?");
- int intrestRate = Integer.parseInt(intrestRateStr);
- String depositStr = showInputDialog("How much will you deposit?");
- double depositAmount = Double.parseDouble(depositStr);
- DecimalFormat pounds = new DecimalFormat("£###,##0.00");
- double amountInterest = calcAmount(intrestRate, depositAmount);
- String bonusStr;
- double bonus = Double.parseDouble(bonusStr);
- if (amountInterest >= 5000.00)
- bonus = (+100.00);
- else if (amountInterest >= 1000.00)
- bonus = (+50.00);
- double finalAmountInterestBonus = bonus + amountInterest;
- showMessageDialog(null,
- "Your savings will become " + pounds.format(finalAmountInterestBonus));
- }
- private static double calcAmount(int intRate, double depAmount) {
- double result = depAmount*(1.0 + intRate/100.0);
- return result;
- }
- }
- String bonusStr;
- double bonus = Double.parseDouble(bonusStr);
- String bonusStr = "123.456";
- double bonus = Double.parseDouble(bonusStr);
- String bonusStr;
- double bonus = Double.parseDouble(bonusStr);
- String bonusStr;
- double bonus = Double.parseDouble(bonusStr);
- String bonusStr = "0";
Add Comment
Please, Sign In to add comment