Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class Donations {
- public static void main(String[] args){
- final double adminFee = 0.05;
- Campaign campaign1 = new Campaign("IT Student Scholarship Fund", "Non Profit", 15000, 2000+3600+1255);
- Campaign campaign2 = new Campaign();
- printReport(campaign1, campaign2);
- }
- public static Campaign getCampName(){
- Campaign aCampaign = new Campaign();
- String campName;
- aCampaign.setCampName(JOptionPane.showInputDialog("Enter the name of your Campaign: ");
- return aCampaign;
- }
- public static String getCampType(){
- String campType;
- do{
- campType = JOptionPane.showInputDialog("Enter the type of campaign you have(Non Profit or For Profit)");
- if((!campType.equalsIgnoreCase("Non Profit") || (!campType.equalsIgnoreCase("For Profit"))){
- JOptionPane.showMessageDialog(null, "Error: Please enter either Non Profit or For Profit for your campaign type.");
- }
- }while(!campType.equalsIgnoreCase("Non Profit") || (!campType.equalsIgnoreCase("For Profit")));
- return campType;
- }
- public static double getCampGoal(){
- double campGoal=10000.0;
- String defaultOrNo;
- boolean trigger= false;
- defaultOrNo = JOptionPane.showInputDialog("Would you like to use the default goal amount of 10000.0?");
- if(defaultOrNo.equalsIgnoreCase("Yes"){
- campGoal=10000.0;
- }else if(defaultOrNo.equalsIgnoreCase("No"){
- do{
- try{
- campGoal=JOptionPane.showInputDialog("Please enter your goal amount: ");
- }catch(NumberFormatException e){
- campGoal=-1;
- JOptionPane.showMessageDialog(null, "Error: please enter a valid goal amount: ");
- trigger = true;
- }
- if(campGoal<0.0 || campGoal>25000.0){
- JOptionPane.showMessageDialog(null, "Error: please enter a valid goal amount (1-25000)");
- trigger = true;
- }
- }while(trigger = true && (campGoal<0.0 || campGoal>25000.0));
- return campGoal;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement