Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.37 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2. public class Donations {
  3.  
  4.    public static void main(String[] args){
  5.       final double adminFee = 0.05;
  6.       Campaign campaign1 = new Campaign("IT Student Scholarship Fund", "Non Profit", 15000, 2000+3600+1255);
  7.       Campaign campaign2 = new Campaign();
  8.       printReport(campaign1, campaign2);
  9.    }
  10.    
  11.    public static Campaign getCampName(){
  12.       Campaign aCampaign = new Campaign();
  13.        
  14.       String campName;
  15.       aCampaign.setCampName(JOptionPane.showInputDialog("Enter the name of your Campaign: ");
  16.  
  17.       return aCampaign;
  18.    }
  19.    
  20.    public static String getCampType(){
  21.  
  22.       String campType;
  23.  
  24.       do{
  25.      
  26.          campType = JOptionPane.showInputDialog("Enter the type of campaign you have(Non Profit or For Profit)");
  27.          if((!campType.equalsIgnoreCase("Non Profit") || (!campType.equalsIgnoreCase("For Profit"))){
  28.              
  29.             JOptionPane.showMessageDialog(null, "Error: Please enter either Non Profit or For Profit for your campaign type.");
  30.          }
  31.          
  32.       }while(!campType.equalsIgnoreCase("Non Profit") || (!campType.equalsIgnoreCase("For Profit")));
  33.        
  34.       return campType;
  35.     }
  36.      
  37.     public static double getCampGoal(){
  38.        
  39.       double campGoal=10000.0;
  40.       String defaultOrNo;
  41.       boolean trigger= false;
  42.        
  43.          defaultOrNo = JOptionPane.showInputDialog("Would you like to use the default goal amount of 10000.0?");
  44.             if(defaultOrNo.equalsIgnoreCase("Yes"){
  45.                campGoal=10000.0;
  46.             }else if(defaultOrNo.equalsIgnoreCase("No"){
  47.  
  48.                do{
  49.  
  50.                   try{
  51.  
  52.                       campGoal=JOptionPane.showInputDialog("Please enter your goal amount: ");
  53.  
  54.                   }catch(NumberFormatException e){
  55.  
  56.                       campGoal=-1;
  57.  
  58.                       JOptionPane.showMessageDialog(null, "Error: please enter a valid goal amount: ");
  59.  
  60.                       trigger = true;
  61.  
  62.                   }
  63.                   if(campGoal<0.0 || campGoal>25000.0){
  64.                      JOptionPane.showMessageDialog(null, "Error: please enter a valid goal amount (1-25000)");
  65.                      trigger = true;
  66.                 }
  67.                
  68.                }while(trigger = true && (campGoal<0.0 || campGoal>25000.0));
  69.                        
  70.           return campGoal;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement