Savings - { IO.reportBadInput(); return; } int month = 0;...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class Savings { public static void main(String[] args) { System.out.print("Enter the initial deposit: "); double deposit = IO.readDouble(); if (deposit < 0) { IO.reportBadInput(); return; } if (deposit == 0) { IO.outputIntAnswer(0); return; } double initial = deposit; System.out.print("Enter monthly interest rate: "); double rate = IO.readDouble();
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { IO.reportBadInput(); return; } int month = 0; do { System.out.print(&quot;Enter the amount to deposit: &quot;); double added = IO.readDouble(); if (added &lt; 0) { IO.reportBadInput(); return; } double interest = (deposit + added) * rate; deposit += added + interest; month ++; } while (deposit &lt; initial * 2); IO.outputIntAnswer(month); } }...
View Full Document

Ask a homework question - tutors are online