Informatics 1a
Informatics 1a
import javax.swing.JOptionPane;
int year = 1;
int choice;
do {
choice = Integer.parseInt(JOptionPane.showInputDialog("Do you wish to
see the balance after year " + year + "?\nEnter 1 for Yes, 0 to exit:"));
if (choice == 1) {
double balance = calculateBalance(investmentAmount, year);
JOptionPane.showMessageDialog(null, "Balance after year " + year +
": $" + balance);
year++;
} else if (choice != 0) {
JOptionPane.showMessageDialog(null, "Invalid input. Please enter 1
to view balance or 0 to exit.");
}
} while (choice != 0);
}
return balance;
}
}
Question 2
import javax.swing.JOptionPane;
Question 3
import javax.swing.JOptionPane;
count++;
}
}
}
Question 4
import javax.swing.JOptionPane;
Question 5
import javax.swing.JOptionPane;
processMarks(numStudents, numModules);
}